List of usage examples for java.util.logging Level WARNING
Level WARNING
To view the source code for java.util.logging Level WARNING.
Click Source Link
From source file:org.jenkinsci.test.acceptance.update_center.MockUpdateCenter.java
public void ensureRunning() { if (original != null) { return;/*from w ww.j av a 2s. c o m*/ } // TODO this will likely not work on arbitrary controllers, so perhaps limit to the default WinstoneController Jenkins jenkins = injector.getInstance(Jenkins.class); List<String> sites = new UpdateCenter(jenkins).getJson("tree=sites[url]").findValuesAsText("url"); if (sites.size() != 1) { // TODO ideally it would rather delegate to all of them, but that implies deprecating CachedUpdateCenterMetadataLoader.url and using whatever site(s) Jenkins itself specifies LOGGER.log(Level.WARNING, "found an unexpected number of update sites: {0}", sites); return; } UpdateCenterMetadata ucm; try { ucm = ucmd.get(jenkins); } catch (IOException x) { LOGGER.log(Level.WARNING, "cannot load data for mock update center", x); return; } JSONObject all; try { all = new JSONObject(ucm.originalJSON); all.remove("signature"); JSONObject plugins = all.getJSONObject("plugins"); LOGGER.info(() -> "editing JSON with " + plugins.length() + " plugins to reflect " + ucm.plugins.size() + " possible overrides"); for (PluginMetadata meta : ucm.plugins.values()) { String name = meta.getName(); String version = meta.getVersion(); JSONObject plugin = plugins.optJSONObject(name); if (plugin == null) { LOGGER.log(Level.INFO, "adding plugin {0}", name); plugin = new JSONObject().accumulate("name", name); plugins.put(name, plugin); } plugin.put("url", name + ".hpi"); updating(plugin, "version", version); updating(plugin, "gav", meta.gav); updating(plugin, "requiredCore", meta.requiredCore().toString()); updating(plugin, "dependencies", new JSONArray(meta.getDependencies().stream().map(d -> { try { return new JSONObject().accumulate("name", d.name).accumulate("version", d.version) .accumulate("optional", d.optional); } catch (JSONException x) { throw new AssertionError(x); } }).collect(Collectors.toList()))); plugin.remove("sha1"); } } catch (JSONException x) { LOGGER.log(Level.WARNING, "cannot prepare mock update center", x); return; } HttpProcessor proc = HttpProcessorBuilder.create().add(new ResponseServer("MockUpdateCenter")) .add(new ResponseContent()).add(new RequestConnControl()).build(); UriHttpRequestHandlerMapper handlerMapper = new UriHttpRequestHandlerMapper(); String json = "updateCenter.post(\n" + all + "\n);"; handlerMapper.register("/update-center.json", (HttpRequest request, HttpResponse response, HttpContext context) -> { response.setStatusCode(HttpStatus.SC_OK); response.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); }); handlerMapper.register("*.hpi", (HttpRequest request, HttpResponse response, HttpContext context) -> { String plugin = request.getRequestLine().getUri().replaceFirst("^/(.+)[.]hpi$", "$1"); PluginMetadata meta = ucm.plugins.get(plugin); if (meta == null) { LOGGER.log(Level.WARNING, "no such plugin {0}", plugin); response.setStatusCode(HttpStatus.SC_NOT_FOUND); return; } File local = meta.resolve(injector, meta.getVersion()); LOGGER.log(Level.INFO, "serving {0}", local); response.setStatusCode(HttpStatus.SC_OK); response.setEntity(new FileEntity(local)); }); handlerMapper.register("*", (HttpRequest request, HttpResponse response, HttpContext context) -> { String location = original.replace("/update-center.json", request.getRequestLine().getUri()); LOGGER.log(Level.INFO, "redirect to {0}", location); /* TODO for some reason DownloadService.loadJSONHTML does not seem to process the redirect, despite calling setInstanceFollowRedirects(true): response.setStatusCode(HttpStatus.SC_MOVED_TEMPORARILY); response.setHeader("Location", location); */ HttpURLConnection uc = (HttpURLConnection) new URL(location).openConnection(); uc.setInstanceFollowRedirects(true); // TODO consider caching these downloads locally like CachedUpdateCenterMetadataLoader does for the main update-center.json byte[] data = IOUtils.toByteArray(uc); String contentType = uc.getContentType(); response.setStatusCode(HttpStatus.SC_OK); response.setEntity(new ByteArrayEntity(data, ContentType.create(contentType))); }); server = ServerBootstrap.bootstrap(). // could setLocalAddress if using a JenkinsController that requires it setHttpProcessor(proc).setHandlerMapper(handlerMapper).setExceptionLogger(serverExceptionHandler()) .create(); try { server.start(); } catch (IOException x) { LOGGER.log(Level.WARNING, "cannot start mock update center", x); return; } original = sites.get(0); // TODO figure out how to deal with Docker-based controllers which would need to have an IP address for the host String override = "http://" + server.getInetAddress().getHostAddress() + ":" + server.getLocalPort() + "/update-center.json"; LOGGER.log(Level.INFO, "replacing update site {0} with {1}", new Object[] { original, override }); jenkins.runScript( "DownloadService.signatureCheck = false; Jenkins.instance.updateCenter.sites.replaceBy([new UpdateSite(UpdateCenter.ID_DEFAULT, '%s')])", override); }
From source file:com.github.cambierr.jcollector.sender.OpenTsdbHttp.java
@Override public void send(ConcurrentLinkedQueue<Metric> _metrics) throws IOException { JSONArray entries = toJson(_metrics); if (entries.length() == 0) { return;//from w w w.j av a 2 s . c o m } HttpURLConnection conn = (HttpURLConnection) host.openConnection(); if (auth != null) { conn.setRequestProperty("Authorization", auth.getAuth()); } conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); OutputStream body = conn.getOutputStream(); body.write(entries.toString().getBytes()); body.flush(); if (conn.getResponseCode() >= 400) { BufferedReader responseBody = new BufferedReader(new InputStreamReader((conn.getErrorStream()))); String output; StringBuilder sb = new StringBuilder("Could not push data to OpenTSDB through ") .append(getClass().getSimpleName()).append("\n"); while ((output = responseBody.readLine()) != null) { sb.append(output).append("\n"); } Worker.logger.log(Level.WARNING, sb.toString()); throw new IOException(conn.getResponseMessage() + " (" + conn.getResponseCode() + ")"); } }
From source file:io.github.lucaseasedup.logit.backup.BackupManager.java
/** * Creates a new backup of all the accounts stored * in the underlying {@code AccountManager}. * /*from www .j a v a 2s. co m*/ * <p> If this method was called with the {@code asynchronously} * parameter set to {@code true}, a {@code ReportedException} * will not be thrown even if an I/O error occurred. * * @return the created backup file. * * @throws ReportedException if an I/O error occurred, * and it was reported to the logger. */ public File createBackup() { final File backupFile = allocateBackupFileForDate(new Date()); log(Level.INFO, t("createBackup.creating")); try { exportAccounts(backupFile); log(Level.INFO, t("createBackup.success.log").replace("{0}", backupFile.getName())); } catch (IOException ex) { log(Level.WARNING, t("createBackup.fail.log"), ex); ReportedException.throwNew(ex); } return backupFile; }
From source file:com.golemgame.functional.component.BFunctionSource.java
@Override public float generateSignal(float time) { if ((!this.switchActive) && (this.switchType == SwitchType.On)) return 0; float output = 0; try {/*from www. j a v a 2 s . c om*/ //a null pointer here is tied to physics not deleting... output = settings.clampY((float) function.value(settings.clampX(currentTime / settings.getScaleX())) * settings.getScaleY()); } catch (FunctionEvaluationException e) { StateManager.getLogger().log(Level.WARNING, e.getStackTrace().toString()); //send no signal on error } if (this.switchActive && this.switchType == SwitchType.Invert) output = -output; return output; }
From source file:com.opera.core.systems.OperaSettingsTest.java
@Test public void loggingLevelCanBeSet() { settings.logging().setLevel(Level.WARNING); assertEquals(Level.WARNING, settings.logging().getLevel()); }
From source file:com.symbian.driver.core.processors.EmulatorPostProcessor.java
/** * @param lNewFile//from www .j a v a 2s .c om */ public static final void restoreFile(File lNewFile) { LOGGER.info("Restoring old file: " + lNewFile); if (lNewFile.isFile()) { try { if (lNewFile.delete() && !new File(lNewFile.getCanonicalPath() + BACKUP).renameTo(lNewFile)) { LOGGER.log(Level.SEVERE, "Could not restore file: " + lNewFile.toString()); } } catch (IOException lIOException) { LOGGER.log(Level.SEVERE, "Could not restore file: " + lNewFile.toString(), lIOException); } } else { LOGGER.log(Level.WARNING, "Could not find file to restore: " + lNewFile.toString()); } }
From source file:n3phele.storage.swift.CloudStorageImpl.java
@Override public boolean createBucket(Repository repo) throws ForbiddenException { SwiftClient swiftClient = null;/*from w w w .j a v a 2 s .co m*/ try { Credential credential = repo.getCredential().decrypt(); Access access; try { access = getAccess(repo.getTarget(), credential.getAccount(), credential.getSecret()); } catch (UniformInterfaceException e) { int status = e.getResponse().getStatus(); if (status == 401) throw new ForbiddenException("Invalid credentials entered"); throw e; } swiftClient = new SwiftClient(access, getRegion(repo)); Map<String, String> params = new HashMap<String, String>(); params.put("delimiter", "/"); params.put("limit", "1"); List<SwiftObject> content = swiftClient.listObjects(getContainer(repo), params); // it exists and the current account owns it return false; } catch (UniformInterfaceException e) { int status = e.getResponse().getStatus(); if (status == 401) throw new ForbiddenException( "Bucket " + repo.getRoot() + " has already been created by another user."); if (status == 404) { boolean result = swiftClient.createContainer(getContainer(repo)); return result; } log.log(Level.WARNING, "Swift getObject exception", e); throw e; } }
From source file:com.github.cc007.headsinventory.HeadsInventory.java
/** * Setup permissions// w w w . j a va2s . c om * * @return True: Setup correctly, Didn't setup correctly */ private boolean setupPermissions() { RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager() .getRegistration(net.milkbowl.vault.permission.Permission.class); if (permissionProvider != null) { permission = permissionProvider.getProvider(); } if (permission == null) { getLogger().log(Level.WARNING, "Could not hook Vault!"); } else { getLogger().log(Level.INFO, "Hooked Vault!"); } return (permission != null); }
From source file:net.chrissearle.spring.twitter.spring.Twitter4jFollowService.java
private List<String> retrieveFollowing() { List<String> usernames = new ArrayList<String>(); try {/* w ww . ja v a2 s . c o m*/ usernames = populateUsernameList(twitter.getFriendsIDs()); } catch (TwitterException e) { final String message = new StringBuilder().append("Unable to retrieve user details due to ") .append(e.getMessage()).toString(); if (logger.isLoggable(Level.WARNING)) { logger.warning(message); } throw new TwitterServiceException(message, e); } return usernames; }
From source file:com.neophob.sematrix.core.output.E1_31Device.java
@Override protected void sendBufferToReceiver(int universeId, byte[] buffer) { if (this.initialized) { byte[] data = dataPacket.assembleNewE131Packet(this.sequenceID++, universeId, buffer); packet.setData(data);/*ww w . java2 s .c o m*/ packet.setLength(data.length); if (this.sendMulticast) { // multicast - universe number must be in lower 2 bytes byte[] addr = new byte[4]; addr[0] = (byte) 239; addr[1] = (byte) 255; addr[2] = (byte) (universeId >> 8); addr[3] = (byte) (universeId & 255); InetAddress iaddr; try { iaddr = InetAddress.getByAddress(addr); packet.setAddress(iaddr); } catch (UnknownHostException e) { LOG.log(Level.WARNING, "Failed to set target address!", e); } } try { dsocket.send(packet); } catch (IOException e) { errorCounter++; LOG.log(Level.WARNING, "failed to send E1.31 data.", e); } } }