use of org.kohsuke.accmod.Restricted in project workflow-cps-plugin by jenkinsci.
the class CpsFlowExecution method suspendAll.
@Restricted(DoNotUse.class)
@Terminator
public static void suspendAll() {
CpsFlowExecution exec = null;
try (Timeout t = Timeout.limit(3, TimeUnit.MINUTES)) {
// TODO some complicated sequence of calls to Futures could allow all of them to run in parallel
LOGGER.fine("starting to suspend all executions");
for (FlowExecution execution : FlowExecutionList.get()) {
if (execution instanceof CpsFlowExecution) {
LOGGER.log(Level.FINE, "waiting to suspend {0}", execution);
exec = (CpsFlowExecution) execution;
// Like waitForSuspension but with a timeout:
if (exec.programPromise != null) {
exec.programPromise.get(1, TimeUnit.MINUTES).scheduleRun().get(1, TimeUnit.MINUTES);
}
}
}
LOGGER.fine("finished suspending all executions");
} catch (Exception x) {
LOGGER.log(Level.WARNING, "problem suspending " + exec, x);
}
}
use of org.kohsuke.accmod.Restricted in project workflow-cps-plugin by jenkinsci.
the class Snippetizer method getQuasiDescriptors.
@Restricted(NoExternalUse.class)
public Collection<QuasiDescriptor> getQuasiDescriptors(boolean advanced) {
TreeSet<QuasiDescriptor> t = new TreeSet<>();
for (StepDescriptor d : StepDescriptor.all()) {
if (d.isAdvanced() == advanced) {
t.add(new QuasiDescriptor(d));
if (d.isMetaStep()) {
DescribableModel<?> m = DescribableModel.of(d.clazz);
Collection<DescribableParameter> parameters = m.getParameters();
if (parameters.size() == 1) {
DescribableParameter delegate = parameters.iterator().next();
if (delegate.isRequired()) {
if (delegate.getType() instanceof HeterogeneousObjectType) {
// TODO HeterogeneousObjectType does not yet expose symbol information, and DescribableModel.symbolOf is private
for (DescribableModel<?> delegateOptionSchema : ((HeterogeneousObjectType) delegate.getType()).getTypes().values()) {
Class<?> delegateOptionType = delegateOptionSchema.getType();
Descriptor<?> delegateDescriptor = Jenkins.getActiveInstance().getDescriptorOrDie(delegateOptionType.asSubclass(Describable.class));
Set<String> symbols = SymbolLookup.getSymbolValue(delegateDescriptor);
if (!symbols.isEmpty()) {
t.add(new QuasiDescriptor(delegateDescriptor));
}
}
}
}
}
// TODO currently not handling metasteps with other parameters, either required or (like GenericSCMStep) not
}
}
}
return t;
}
use of org.kohsuke.accmod.Restricted in project vsphere-cloud-plugin by jenkinsci.
the class CloudProvisioningAlgorithm method toBigInteger.
/**
* Turns two 64-bit long numbers into a positive 128-bit {@link BigInteger}
* that's in the range 0 to 2<sup>128</sup>-1.
* <p>
* <b>Note:</b> This is only package-level access for unit-testing.
* </p>
*
* @param msb
* The most-significant 64 bits.
* @param lsb
* The least-significant 64 bits.
* @return A {@link BigInteger}.
*/
@Restricted(NoExternalUse.class)
static BigInteger toBigInteger(final long msb, final long lsb) {
final byte[] bytes = new byte[17];
int b = 0;
// ensure we're all positive
bytes[b++] = (byte) 0;
bytes[b++] = (byte) (msb >> 56);
bytes[b++] = (byte) (msb >> 48);
bytes[b++] = (byte) (msb >> 40);
bytes[b++] = (byte) (msb >> 32);
bytes[b++] = (byte) (msb >> 24);
bytes[b++] = (byte) (msb >> 16);
bytes[b++] = (byte) (msb >> 8);
bytes[b++] = (byte) (msb);
bytes[b++] = (byte) (lsb >> 56);
bytes[b++] = (byte) (lsb >> 48);
bytes[b++] = (byte) (lsb >> 40);
bytes[b++] = (byte) (lsb >> 32);
bytes[b++] = (byte) (lsb >> 24);
bytes[b++] = (byte) (lsb >> 16);
bytes[b++] = (byte) (lsb >> 8);
bytes[b++] = (byte) (lsb);
final BigInteger bigNumber = new BigInteger(bytes);
return bigNumber;
}
use of org.kohsuke.accmod.Restricted in project access-modifier by kohsuke.
the class EnforcerMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping access modifier checks");
return;
}
try {
File outputDir = new File(project.getBuild().getOutputDirectory());
List<URL> dependencies = new ArrayList<URL>();
for (Artifact a : (Collection<Artifact>) project.getArtifacts()) dependencies.add(a.getFile().toURI().toURL());
URL outputURL = outputDir.toURI().toURL();
dependencies.add(outputURL);
final boolean[] failed = new boolean[1];
Checker checker = new Checker(new URLClassLoader(dependencies.toArray(new URL[dependencies.size()]), getClass().getClassLoader()), new ErrorListener() {
public void onError(Throwable t, Location loc, String msg) {
String locMsg = loc + " " + msg;
if (failOnError) {
getLog().error(locMsg, t);
} else {
getLog().warn(locMsg, t);
}
failed[0] = true;
}
public void onWarning(Throwable t, Location loc, String msg) {
getLog().warn(loc + " " + msg, t);
}
}, properties != null ? properties : new Properties());
{
// if there's restriction list in the inspected module itself, load it as well
InputStream self = null;
try {
self = new URL(outputURL, "META-INF/annotations/" + Restricted.class.getName()).openStream();
} catch (IOException e) {
}
if (self != null)
checker.loadRestrictions(self, true);
}
// perform checks
checker.check(outputDir);
if (failed[0]) {
String message = "Access modifier checks failed. See the details above";
if (failOnError) {
throw new MojoFailureException(message);
} else {
getLog().warn(message);
}
}
} catch (IOException e) {
throw new MojoExecutionException("Failed to enforce @Restricted constraints", e);
}
}
use of org.kohsuke.accmod.Restricted in project promoted-builds-plugin by jenkinsci.
the class PromotedBuildAction method canPromote.
@Restricted(NoExternalUse.class)
public boolean canPromote(String processName) {
PromotionProcess process = getPromotionProcess(processName);
ManualCondition manualCondition = null;
if (process != null) {
manualCondition = (ManualCondition) process.getPromotionCondition(ManualCondition.class.getName());
}
return PromotionPermissionHelper.hasPermission(getProject(), manualCondition);
}
Aggregations