use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class ScannerReportViewerApp method getLastUsedReport.
@CheckForNull
private File getLastUsedReport() {
File f = new File(System.getProperty("java.io.tmpdir"), ".last_batch_report_dir");
if (f.exists()) {
String path;
try {
path = FileUtils.readFileToString(f, StandardCharsets.UTF_8);
} catch (IOException e) {
return null;
}
File lastReport = new File(path);
if (lastReport.exists() && lastReport.isDirectory()) {
return lastReport;
}
}
return null;
}
use of javax.annotation.CheckForNull in project blueocean-plugin by jenkinsci.
the class BlueI18n method getBundle.
@CheckForNull
private JSONObject getBundle(BundleParams bundleParams, Locale locale) {
PluginWrapper plugin = bundleParams.getPlugin();
if (plugin == null) {
return null;
}
try {
ResourceBundle resourceBundle = ResourceBundle.getBundle(bundleParams.bundleName, locale, plugin.classLoader);
JSONObject bundleJSON = new JSONObject();
for (String key : resourceBundle.keySet()) {
bundleJSON.put(key, resourceBundle.getString(key));
}
return bundleJSON;
} catch (MissingResourceException e) {
// fall through and return null.
}
return null;
}
use of javax.annotation.CheckForNull in project promoted-builds-plugin by jenkinsci.
the class PromotionProcess method considerPromotion2.
@CheckForNull
public Future<Promotion> considerPromotion2(AbstractBuild<?, ?> build, List<ParameterValue> params) throws IOException {
if (!isActive())
// not active
return null;
PromotedBuildAction a = build.getAction(PromotedBuildAction.class);
// if it's already promoted, no need to do anything.
if (a != null && a.contains(this))
return null;
LOGGER.fine("Considering the promotion of " + build + " via " + getName() + " with parameters");
Status qualification = isMet(build);
if (qualification == null)
// not this time
return null;
LOGGER.fine("Promotion condition of " + build + " is met: " + qualification);
// TODO: define promotion cause
Future<Promotion> f = promote2(build, new UserCause(), qualification, params);
if (f == null)
LOGGER.warning(build + " qualifies for a promotion but the queueing failed.");
return f;
}
use of javax.annotation.CheckForNull in project promoted-builds-plugin by jenkinsci.
the class PromotionProcess method considerPromotion2.
/**
* Checks if the build is promotable, and if so, promote it.
*
* @param build Build to be promoted
* @return
* {@code null} if the build was not promoted, otherwise Future that kicks in when the build is completed.
* @throws IOException
*/
@CheckForNull
public Future<Promotion> considerPromotion2(AbstractBuild<?, ?> build) throws IOException {
LOGGER.fine("Considering the promotion of " + build + " via " + getName() + " without parmeters");
// If the build has manual approvals, use the parameters from it
List<ParameterValue> params = new ArrayList<ParameterValue>();
List<ManualApproval> approvals = build.getActions(ManualApproval.class);
for (ManualApproval approval : approvals) {
if (approval.name.equals(getName())) {
LOGGER.fine("Getting parameters from existing manual promotion");
params = approval.badge.getParameterValues();
LOGGER.finer("Using paramters: " + params.toString());
}
}
return considerPromotion2(build, params);
}
use of javax.annotation.CheckForNull in project promoted-builds-plugin by jenkinsci.
the class ItemPathResolver method findPath.
@CheckForNull
private static Item findPath(@CheckForNull ItemGroup base, @Nonnull String path) {
@CheckForNull ItemGroup<?> pointer = base;
final StringTokenizer t = new StringTokenizer(path, "/");
while (pointer != null && t.hasMoreTokens()) {
String current = t.nextToken();
if (current.equals("..")) {
if (pointer instanceof Item) {
Item currentItem = (Item) pointer;
pointer = currentItem.getParent();
} else {
// Cannot go upstairs
pointer = null;
}
} else if (current.equals(".")) {
// Do nothing, we stay on the same level
} else {
// Resolve the level beneath
final Item item = pointer.getItem(current);
if (!t.hasMoreTokens()) {
// Last token => we consider it as a required item
return item;
}
if (item instanceof ItemGroup<?>) {
pointer = (ItemGroup<?>) item;
} else {
// Wrong path, we got to item before finishing the requested path
pointer = null;
}
}
}
// Cannot retrieve the path => exit with null
if (pointer instanceof Item) {
return (Item) pointer;
}
return null;
}
Aggregations