use of org.kohsuke.stapler.export.Exported in project blueocean-plugin by jenkinsci.
the class BranchImpl method getBranch.
@Exported(name = BRANCH, inline = true)
public Branch getBranch() {
ObjectMetadataAction om = job.getAction(ObjectMetadataAction.class);
PrimaryInstanceMetadataAction pima = job.getAction(PrimaryInstanceMetadataAction.class);
String url = om != null && om.getObjectUrl() != null ? om.getObjectUrl() : null;
return new Branch(url, pima != null);
}
use of org.kohsuke.stapler.export.Exported in project configuration-as-code-plugin by jenkinsci.
the class BaseConfigurator method describe.
public Set<Attribute> describe() {
Set<Attribute> attributes = new HashSet<>();
final Class<T> target = getTarget();
final PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(target);
LOGGER.log(Level.FINE, "Found {0} properties for {1}", new Object[] { properties.length, target });
for (PropertyDescriptor p : properties) {
final String name = p.getName();
LOGGER.log(Level.FINER, "Processing {0} property", name);
final Method setter = p.getWriteMethod();
if (setter == null) {
LOGGER.log(Level.FINE, "Ignored {0} property: read only", name);
// read only
continue;
}
if (setter.getAnnotation(Deprecated.class) != null) {
LOGGER.log(Level.FINE, "Ignored {0} property: deprecated", name);
// not actually public
continue;
}
if (setter.getAnnotation(Restricted.class) != null) {
LOGGER.log(Level.FINE, "Ignored {0} property: restricted", name);
// not actually public - require access-modifier 1.12
continue;
}
// FIXME move this all into cleaner logic to discover property type
Type type = setter.getGenericParameterTypes()[0];
Attribute attribute = detectActualType(name, type);
if (attribute == null)
continue;
attributes.add(attribute);
final Method getter = p.getReadMethod();
if (getter != null) {
final Exported annotation = getter.getAnnotation(Exported.class);
if (annotation != null && isNotBlank(annotation.name())) {
attribute.preferredName(annotation.name());
}
}
// See https://github.com/jenkinsci/structs-plugin/pull/18
final Symbol s = setter.getAnnotation(Symbol.class);
if (s != null) {
attribute.preferredName(s.value()[0]);
}
}
return attributes;
}
use of org.kohsuke.stapler.export.Exported in project configuration-as-code-plugin by jenkinsci.
the class Attribute method locateGetter.
@CheckForNull
private static Method locateGetter(Class<?> clazz, @NonNull String fieldName) {
final String upname = StringUtils.capitalize(fieldName);
final List<String> accessors = Arrays.asList("get" + upname, "is" + upname);
for (Method method : clazz.getMethods()) {
if (method.getParameterCount() != 0)
continue;
if (accessors.contains(method.getName())) {
return method;
}
final Exported exported = method.getAnnotation(Exported.class);
if (exported != null && exported.name().equalsIgnoreCase(fieldName)) {
return method;
}
}
return null;
}
use of org.kohsuke.stapler.export.Exported in project workflow-job-plugin by jenkinsci.
the class FlowGraphAction method getNodes.
@Exported
public Collection<? extends FlowNode> getNodes() {
FlowExecution exec = run.getExecution();
if (exec == null) {
return Collections.emptySet();
}
List<FlowNode> nodes = new ArrayList<>();
FlowGraphWalker walker = new FlowGraphWalker(exec);
for (FlowNode n : walker) {
nodes.add(n);
}
Collections.reverse(nodes);
return nodes;
}
use of org.kohsuke.stapler.export.Exported in project jenkins by jenkinsci.
the class Fingerprint method _getUsages.
// this is for remote API
@Exported(name = "usage")
@NonNull
public List<RangeItem> _getUsages() {
List<RangeItem> r = new ArrayList<>();
final Jenkins instance = Jenkins.get();
for (Map.Entry<String, RangeSet> e : usages.entrySet()) {
final String itemName = e.getKey();
if (instance.hasPermission(Jenkins.ADMINISTER) || canDiscoverItem(itemName)) {
r.add(new RangeItem(itemName, e.getValue()));
}
}
return r;
}
Aggregations