List of usage examples for java.net MalformedURLException getMessage
public String getMessage()
From source file:com.ibm.jaggr.core.impl.options.OptionsImpl.java
/** * Loads the Options properties from the aggregator properties file * into the specified properties object. If the properties file * does not exist, then try to load from the bundle. * * @param props/*from w w w .ja v a2s . c o m*/ * The properties object to load. May be initialized with default * values. * @return The properties file specified by {@code props}. */ protected Properties loadProps(Properties props) { // try to load the properties file first from the user's home directory File file = getPropsFile(); if (file != null) { // Try to load the file from the user's home directory if (file.exists()) { try { URL url = file.toURI().toURL(); loadFromUrl(props, url); } catch (MalformedURLException ex) { if (log.isLoggable(Level.WARNING)) { log.log(Level.WARNING, ex.getMessage(), ex); } } } } return props; }
From source file:org.apache.nifi.processors.aws.wag.AbstractAWSGatewayApiProcessor.java
protected void logRequest(ComponentLog logger, URI endpoint, GenericApiGatewayRequest request) { try {// www. j a va 2 s . c o m logger.debug("\nRequest to remote service:\n\t{}\t{}\t\n{}", new Object[] { endpoint.toURL().toExternalForm(), request.getHttpMethod(), getLogString(request.getHeaders()) }); } catch (MalformedURLException e) { logger.debug(e.getMessage()); } }
From source file:org.apache.nifi.processors.aws.wag.AbstractAWSGatewayApiProcessor.java
protected void logResponse(ComponentLog logger, GenericApiGatewayResponse response) { try {// w w w. j ava 2s. c om logger.debug("\nResponse from remote service:\n\t{}\n{}", new Object[] { response.getHttpResponse().getHttpRequest().getURI().toURL().toExternalForm(), getLogString(response.getHttpResponse().getHeaders()) }); } catch (MalformedURLException e) { logger.debug(e.getMessage()); } }
From source file:JavaFiles.PSIBlastClient.java
/** Ensure that a service proxy is available to call the web service. * /*from ww w . j av a 2 s . c om*/ * @throws ServiceException */ protected void srvProxyConnect() throws ServiceException { printDebugMessage("srvProxyConnect", "Begin", 11); if (this.srvProxy == null) { JDispatcherService_Service service = new JDispatcherService_ServiceLocator(); if (this.getServiceEndPoint() != null) { try { this.srvProxy = service .getJDispatcherServiceHttpPort(new java.net.URL(this.getServiceEndPoint())); } catch (java.net.MalformedURLException ex) { System.err.println(ex.getMessage()); System.err.println("Warning: problem with specified endpoint URL. Default endpoint used."); this.srvProxy = service.getJDispatcherServiceHttpPort(); } } else { this.srvProxy = service.getJDispatcherServiceHttpPort(); } } printDebugMessage("srvProxyConnect", "End", 11); }
From source file:org.commonjava.aprox.core.ctl.ReplicationController.java
private List<? extends ArtifactStore> getRemoteStores(final ReplicationDTO dto) throws AproxWorkflowException { final String apiUrl = dto.getApiUrl(); String remotesUrl = null;//w w w. j a v a 2 s. co m String groupsUrl = null; String hostedUrl = null; try { remotesUrl = buildUrl(apiUrl, "/admin/remotes"); groupsUrl = buildUrl(apiUrl, "/admin/groups"); hostedUrl = buildUrl(apiUrl, "/admin/hosted"); } catch (final MalformedURLException e) { throw new AproxWorkflowException( "Failed to construct store definition-retrieval URL from api-base: {}. Reason: {}", e, apiUrl, e.getMessage()); } // logger.info( "\n\n\n\n\n[AutoProx] Checking URL: {} from:", new Throwable(), url ); final List<ArtifactStore> result = new ArrayList<ArtifactStore>(); HttpGet req = newGet(remotesUrl, dto); HttpResponse response = null; try { response = http.getClient().execute(req); final StatusLine statusLine = response.getStatusLine(); final int status = statusLine.getStatusCode(); if (status == HttpStatus.SC_OK) { final String json = HttpResources.entityToString(response); final StoreListingDTO<RemoteRepository> listing = serializer.readValue(json, serializer .getTypeFactory().constructParametricType(StoreListingDTO.class, RemoteRepository.class)); if (listing != null) { for (final RemoteRepository store : listing.getItems()) { result.add(store); } } } else { throw new AproxWorkflowException(status, "Request: %s failed: %s", remotesUrl, statusLine); } } catch (final ClientProtocolException e) { throw new AproxWorkflowException("Failed to retrieve endpoints from: %s. Reason: %s", e, remotesUrl, e.getMessage()); } catch (final IOException e) { throw new AproxWorkflowException("Failed to read endpoints from: %s. Reason: %s", e, remotesUrl, e.getMessage()); } finally { HttpResources.cleanupResources(req, response, null, http); } req = newGet(groupsUrl, dto); response = null; try { response = http.getClient().execute(req); final StatusLine statusLine = response.getStatusLine(); final int status = statusLine.getStatusCode(); if (status == HttpStatus.SC_OK) { final String json = HttpResources.entityToString(response); final StoreListingDTO<Group> listing = serializer.readValue(json, serializer.getTypeFactory().constructParametricType(StoreListingDTO.class, Group.class)); for (final Group store : listing.getItems()) { result.add(store); } } else { throw new AproxWorkflowException(status, "Request: {} failed: {}", groupsUrl, statusLine); } } catch (final ClientProtocolException e) { throw new AproxWorkflowException("Failed to retrieve endpoints from: {}. Reason: {}", e, groupsUrl, e.getMessage()); } catch (final IOException e) { throw new AproxWorkflowException("Failed to read endpoints from: {}. Reason: {}", e, groupsUrl, e.getMessage()); } finally { HttpResources.cleanupResources(req, response, null, http); } req = newGet(hostedUrl, dto); response = null; try { response = http.getClient().execute(req); final StatusLine statusLine = response.getStatusLine(); final int status = statusLine.getStatusCode(); if (status == HttpStatus.SC_OK) { final String json = HttpResources.entityToString(response); final StoreListingDTO<HostedRepository> listing = serializer.readValue(json, serializer .getTypeFactory().constructParametricType(StoreListingDTO.class, HostedRepository.class)); for (final HostedRepository store : listing.getItems()) { result.add(store); } } else { throw new AproxWorkflowException(status, "Request: %s failed: %s", hostedUrl, statusLine); } } catch (final ClientProtocolException e) { throw new AproxWorkflowException("Failed to retrieve endpoints from: %s. Reason: %s", e, hostedUrl, e.getMessage()); } catch (final IOException e) { throw new AproxWorkflowException("Failed to read endpoints from: %s. Reason: %s", e, hostedUrl, e.getMessage()); } finally { HttpResources.cleanupResources(req, response, null, http); } return result; }
From source file:hudson.plugins.testlink.TestLinkBuilder.java
/** * Called when the job is executed./*from ww w . j a v a 2 s . c om*/ */ @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { LOGGER.log(Level.INFO, "TestLink builder started"); this.failure = false; // TestLink installation listener.getLogger().println(Messages.TestLinkBuilder_PreparingTLAPI()); final TestLinkInstallation installation = DESCRIPTOR.getInstallationByTestLinkName(this.testLinkName); if (installation == null) { throw new AbortException(Messages.TestLinkBuilder_InvalidTLAPI()); } TestLinkHelper.setTestLinkJavaAPIProperties(installation.getTestLinkJavaAPIProperties(), listener); final TestLinkSite testLinkSite; final TestCaseWrapper[] automatedTestCases; final String testLinkUrl = installation.getUrl(); final String testLinkDevKey = installation.getDevKey(); listener.getLogger().println(Messages.TestLinkBuilder_UsedTLURL(testLinkUrl)); try { final String testProjectName = expandVariable(build.getBuildVariableResolver(), build.getEnvironment(listener), getTestProjectName()); final String testPlanName = expandVariable(build.getBuildVariableResolver(), build.getEnvironment(listener), getTestPlanName()); final String platformName = expandVariable(build.getBuildVariableResolver(), build.getEnvironment(listener), getPlatformName()); final String buildName = expandVariable(build.getBuildVariableResolver(), build.getEnvironment(listener), getBuildName()); final String buildNotes = Messages.TestLinkBuilder_Build_Notes(); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "TestLink project name: [" + testProjectName + "]"); LOGGER.log(Level.FINE, "TestLink plan name: [" + testPlanName + "]"); LOGGER.log(Level.FINE, "TestLink platform name: [" + platformName + "]"); LOGGER.log(Level.FINE, "TestLink build name: [" + buildName + "]"); LOGGER.log(Level.FINE, "TestLink build notes: [" + buildNotes + "]"); } // TestLink Site object testLinkSite = this.getTestLinkSite(testLinkUrl, testLinkDevKey, testProjectName, testPlanName, platformName, buildName, buildNotes); if (StringUtils.isNotBlank(platformName) && testLinkSite.getPlatform() == null) listener.getLogger().println(Messages.TestLinkBuilder_PlatformNotFound(platformName)); final String[] customFieldsNames = this.createArrayOfCustomFieldsNames(build.getBuildVariableResolver(), build.getEnvironment(listener)); final Set<ExecutionStatus> executionStatuses = this.getExecutionStatuses(); // Array of automated test cases TestCase[] testCases = testLinkSite.getAutomatedTestCases(customFieldsNames, executionStatuses); // Transforms test cases into test case wrappers automatedTestCases = this.transform(testCases); testCases = null; listener.getLogger() .println(Messages.TestLinkBuilder_ShowFoundAutomatedTestCases(automatedTestCases.length)); // Sorts test cases by each execution order (this info comes from // TestLink) listener.getLogger().println(Messages.TestLinkBuilder_SortingTestCases()); Arrays.sort(automatedTestCases, this.executionOrderComparator); } catch (MalformedURLException mue) { mue.printStackTrace(listener.fatalError(mue.getMessage())); throw new AbortException(Messages.TestLinkBuilder_InvalidTLURL(testLinkUrl)); } catch (TestLinkAPIException e) { e.printStackTrace(listener.fatalError(e.getMessage())); throw new AbortException(Messages.TestLinkBuilder_TestLinkCommunicationError()); } for (TestCaseWrapper tcw : automatedTestCases) { testLinkSite.getReport().addTestCase(tcw); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "TestLink automated test case ID [" + tcw.getId() + "], name [" + tcw.getName() + "]"); } } listener.getLogger().println(Messages.TestLinkBuilder_ExecutingSingleBuildSteps()); this.executeSingleBuildSteps(automatedTestCases.length, testLinkSite, build, launcher, listener); listener.getLogger().println(Messages.TestLinkBuilder_ExecutingIterativeBuildSteps()); this.executeIterativeBuildSteps(automatedTestCases, testLinkSite, build, launcher, listener); // Here we search for test results. The return if a wrapped Test Case // that // contains attachments, platform and notes. try { listener.getLogger().println(Messages.Results_LookingForTestResults()); if (getResultSeekers() != null) { for (ResultSeeker resultSeeker : getResultSeekers()) { LOGGER.log(Level.INFO, "Seeking test results. Using: " + resultSeeker.getDescriptor().getDisplayName()); resultSeeker.seek(automatedTestCases, build, launcher, listener, testLinkSite); } } } catch (ResultSeekerException trse) { trse.printStackTrace(listener.fatalError(trse.getMessage())); throw new AbortException(Messages.Results_ErrorToLookForTestResults(trse.getMessage())); } catch (TestLinkAPIException tlae) { tlae.printStackTrace(listener.fatalError(tlae.getMessage())); throw new AbortException(Messages.TestLinkBuilder_FailedToUpdateTL(tlae.getMessage())); } // This report is used to generate the graphs and to store the list of // test cases with each found status. final Report report = testLinkSite.getReport(); report.tally(); listener.getLogger().println(Messages.TestLinkBuilder_ShowFoundTestResults(report.getTestsTotal())); final TestLinkResult result = new TestLinkResult(report, build); final TestLinkBuildAction buildAction = new TestLinkBuildAction(build, result); build.addAction(buildAction); if (report.getTestsTotal() <= 0 && this.getFailIfNoResults() == Boolean.TRUE) { listener.getLogger().println("No test results found. Setting the build result as FAILURE."); build.setResult(Result.FAILURE); } else if (report.getFailed() > 0) { if (this.failedTestsMarkBuildAsFailure != null && this.failedTestsMarkBuildAsFailure) { listener.getLogger().println("There are failed tests, setting the build result as FAILURE."); build.setResult(Result.FAILURE); } else { listener.getLogger().println("There are failed tests, setting the build result as UNSTABLE."); build.setResult(Result.UNSTABLE); } } else if (this.getFailOnNotRun() != null && this.getFailOnNotRun() && report.getNotRun() > 0) { listener.getLogger().println("There are not run tests, setting the build result as FAILURE."); build.setResult(Result.FAILURE); } LOGGER.log(Level.INFO, "TestLink builder finished"); // end return Boolean.TRUE; }
From source file:argendata.service.impl.DatasetServiceImpl.java
@Override public FacetDatasetResponse searchOnIndexFacetDataset(String terms, String[] queryFacetsFields, Map<String, String> filterValuesMap, List<String> mySortByFields, List<String> myKeywords) { QueryResponse rsp = null;/*from w ww .java2 s . c om*/ try { rsp = resolveIndexQuery(terms, queryFacetsFields, filterValuesMap, mySortByFields, myKeywords); } catch (MalformedURLException e) { logger.fatal("No se puede conectar a solr"); } catch (SolrServerException e) { logger.error(e.getMessage(), e); } List<Dataset> datasets = getDatasets(rsp); Map<String, List<FacetCount>> values = new HashMap<String, List<FacetCount>>(); for (String a : queryFacetsFields) { List<FacetCount> fc = new ArrayList<FacetCount>(); if (rsp.getFacetField(a).getValues() != null) { for (Count c : rsp.getFacetField(a).getValues()) { fc.add(new FacetCount(c.getName(), c.getCount())); } values.put(a, fc); } } return new FacetDatasetResponse(datasets, values); }
From source file:dk.dma.ais.abnormal.analyzer.AbnormalAnalyzerAppModule.java
@Provides @Singleton/*from w w w. ja va 2 s .c o m*/ AisReader provideAisReader() { AisReader aisReader = null; Configuration configuration = getConfiguration(); String aisDatasourceUrlAsString = configuration.getString(CONFKEY_AIS_DATASOURCE_URL); URL aisDataSourceUrl; try { aisDataSourceUrl = new URL(aisDatasourceUrlAsString); } catch (MalformedURLException e) { LOG.error(e.getMessage(), e); return null; } String protocol = aisDataSourceUrl.getProtocol(); LOG.debug("AIS data source protocol: " + protocol); if ("file".equalsIgnoreCase(protocol)) { try { File file = new File(aisDataSourceUrl.getPath()); String path = file.getParent(); String pattern = file.getName(); LOG.debug("AIS data source is file system - " + path + "/" + pattern); aisReader = AisReaders.createDirectoryReader(path, pattern, true); LOG.info("Created AisReader (" + aisReader + ")."); } catch (Exception e) { LOG.error("Failed to create AisReader.", e); } } else if ("tcp".equalsIgnoreCase(protocol)) { try { String host = aisDataSourceUrl.getHost(); int port = aisDataSourceUrl.getPort(); LOG.debug("AIS data source is TCP - " + host + ":" + port); aisReader = AisReaders.createReader(host, port); LOG.info("Created AisReader (" + aisReader + ")."); } catch (Exception e) { LOG.error("Failed to create AisReader.", e); } } return aisReader; }
From source file:edu.du.penrose.systems.fedoraApp.batchIngest.data.BagHandler.java
/** * This routing will try to retrieve a file FOREVER, retrying every 10 seconds, the fedoraApp status screen will be updated * and the the user can abort the ingest from there. If the user aborts the ingest a BagitInvalidException is thrown * /*from w w w . j ava 2 s .c o m*/ * @param rootDir * @param baseUrl * @param bagPayLoad * @param bagName * @throws MalformedURLException * @throws IOException * @throws BagitInvalidException Thrown for invalid bag or user abort (see method description). */ private void fetchNeededFiles(String rootDir, String baseUrl, List<String> bagPayLoad, String bagName) throws MalformedURLException, IOException, BagitInvalidException { for (String payloadUrl : bagPayLoad) { if (payloadUrl.contains("data/")) { String msg = "Fetching " + baseUrl + BagHandler.DEFAULT_BAG_URL_DELIMITER + "/" + payloadUrl; BatchThreadManager.setBatchSetStatus(this.batchOptions.getBatchSetName(), msg); this.logger.info(msg); String getUrl = baseUrl + BagHandler.DEFAULT_BAG_URL_DELIMITER + "/" + payloadUrl; String outputPathAndFile = rootDir + bagName + "/" + payloadUrl; /** * Let's try to fetch bagit file, if we can't, we retry every 10 seconds, We will top logging after 10 attempts, but * will hang here forever! The fedoraApp status screen is updated and the user should be able to click the * 'Stop Ingest' button. */ boolean fetchReady = false; int logErrorCount = 0; do { try { org.apache.commons.io.FileUtils.copyURLToFile(new URL(getUrl), new File(outputPathAndFile)); fetchReady = true; } catch (MalformedURLException e) { this.logger.error("Malformed URL in bagit file: Aborting ingest: " + e.getMessage()); FileUtil.deleteDirectoryTree(new File(this.myBagDirectoryPath)); throw new BagitInvalidException(e.getMessage()); } catch (ConnectException e) { logErrorCount++; BatchThreadManager.setBatchSetStatus(this.batchOptions.getBatchSetName(), "ERROR: Unable to fetch File:" + getUrl + "-" + e.getMessage()); if (logErrorCount < 10) { this.logger.error("Unable to fetch bagit file:" + getUrl + "-" + e.getMessage()); } if (logErrorCount == 10) { this.logger .error("Still unable to fetch bagit File, this error will longer be logged."); } try { Thread.sleep(10 * 1000); } catch (InterruptedException e1) { } } catch (Exception e) { this.logger.error("Bagit Exception: Aborting ingest: " + e.getMessage()); FileUtil.deleteDirectoryTree(new File(this.myBagDirectoryPath)); throw new BagitInvalidException(e.getMessage()); } finally { /* * We may be stuck in this loop if we are unable to retrieve files from the server. Fortunately the use * can stop the ingest through the manual ingest gui. We handle that condition here. */ if (!BatchIngestThreadManager.isBatchSetThreadExists(this.batchOptions.getBatchSetName())) { throw new BagitInvalidException(FILE_TRANSFER_ABORTED); } String status = BatchThreadManager.getBatchSetStatus(this.batchOptions.getBatchSetName()); if (status.equals(BatchThreadManager.USER_HARD_STOP_RECIEVED) || status.equals(BatchIngestThreadManager.USER_STOP_RECIEVED)) { throw new BagitInvalidException(FILE_TRANSFER_ABORTED); } } } while (!fetchReady); } } }
From source file:jomr5bphotos.Model.java
public void LoadPictureJSON() throws MalformedURLException, IOException, Exception { String urlString = "http://dalemusser.net/data/nocaltrip/photos.json"; //initiate url URL url;/*from w ww. j a va2 s . co m*/ try { url = new URL(urlString); } catch (MalformedURLException e) { System.out.println("The URL was malformed..."); throw e; } //retrieve JSON object String json = ""; try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()))) { String line = in.readLine(); while (line != null) { json += line; line = in.readLine(); } } catch (IOException e) { System.out.println("Failed to load JSON document: " + e.getMessage()); throw e; } parseJSON(json); }