@SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") @Override public void addAction(@Nonnull Action a) { if (a == null) { throw new IllegalArgumentException("Action must be non-null"); } super.getActions().add(a); }
List<Action> current = getActions(); boolean found = false; for (Action a2 : current) { addAction(a);
@Override public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) { Object returnedResult = super.getDynamic(token, req, rsp); if (returnedResult == null){ //check transient actions too for(Action action: getTransientActions()){ String urlName = action.getUrlName(); if (urlName == null) { continue; } if (urlName.equals(token)) { return action; } } // Next/Previous Build links on an action page (like /job/Abc/123/testReport) // will also point to same action (/job/Abc/124/testReport), but other builds // may not have the action.. tell browsers to redirect up to the build page. returnedResult = new RedirectUp(); } return returnedResult; }
/** * Gets the action (first instance to be found) of a specified type that contributed to this build. * * @param type * @return The action or <code>null</code> if no such actions exist. * @see #getActions(Class) */ public <T extends Action> T getAction(Class<T> type) { // Shortcut: if the persisted list has one, return it. for (Action a : getActions()) { if (type.isInstance(a)) { return type.cast(a); } } // Otherwise check transient factories. for (TransientActionFactory<?> taf : TransientActionFactory.factoriesFor(getClass(), type)) { for (Action a : createFor(taf)) { if (type.isInstance(a)) { return type.cast(a); } } } return null; }
SCMSourceOwner owner = getOwner(); if (owner instanceof Actionable) { GitHubLink repoLink = ((Actionable) owner).getAction(GitHubLink.class); if (repoLink != null) { String url; for (GitHubDefaultBranch p : ((Actionable) owner).getActions(GitHubDefaultBranch.class)) { if (StringUtils.equals(getRepoOwner(), p.getRepoOwner()) && StringUtils.equals(repository, p.getRepository())
/** * {@inheritDoc} * A {@link RunAction2} is handled specially. */ @SuppressWarnings("deprecation") @Override public void addAction(@Nonnull Action a) { super.addAction(a); if (a instanceof RunAction2) { ((RunAction2) a).onAttached(this); } else if (a instanceof RunAction) { ((RunAction) a).onAttached(this); } }
@Override protected @Nonnull SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder builder = super.makeSearchIndex() .add("console") .add("changes"); for (Action a : getAllActions()) { if(a.getIconFileName()!=null) builder.add(a.getUrlName()); } return builder; }
public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) { for (Action a : getAllActions()) { if(a==null) continue; // be defensive String urlName = a.getUrlName(); if(urlName==null) continue; if(urlName.equals(token)) return a; } return null; }
private boolean filter(Item item) { return !(item instanceof Actionable) || !defaultBranchOnly || ((Actionable) item).getAction(PrimaryInstanceMetadataAction.class) != null; }
/** * Gets all actions of a specified type that contributed to this object. * * @param type The type of action to return. * @return an unmodifiable, possible empty list * @see #getAction(Class) */ @Nonnull public <T extends Action> List<T> getActions(Class<T> type) { List<T> _actions = Util.filter(getActions(), type); for (TransientActionFactory<?> taf : TransientActionFactory.factoriesFor(getClass(), type)) { _actions.addAll(Util.filter(createFor(taf), type)); } return Collections.unmodifiableList(_actions); }
((Actionable) executable).addAction(action);
@Override protected @Nonnull SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder builder = super.makeSearchIndex() .add("console") .add("changes"); for (Action a : getAllActions()) { if(a.getIconFileName()!=null) builder.add(a.getUrlName()); } return builder; }
public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response, String view) throws JellyException, IOException { WebApp webApp = WebApp.getCurrent(); final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript(view); if (s!=null) { JellyFacet facet = webApp.getFacet(JellyFacet.class); request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us request.setAttribute("mode","side-panel"); // run sidepanel but ignore generated HTML facet.scriptInvoker.invokeScript(request,response,new Script() { public Script compile() throws JellyException { return this; } public void run(JellyContext context, XMLOutput output) throws JellyTagException { Functions.initPageVariables(context); s.run(context,output); } },self,new XMLOutput(new DefaultHandler())); } else if (self instanceof Actionable) { // fallback this.addAll(((Actionable)self).getAllActions()); } return this; } }
private synchronized boolean isDeclarativeRun(@Nonnull FlowExecution execution) { if (!declarativeRuns.containsKey(execution)) { boolean isDeclarative = false; try { FlowExecutionOwner owner = execution.getOwner(); if (owner != null && owner.getExecutable() instanceof Actionable) { if (((Actionable) owner.getExecutable()).getAction(ExecutionModelAction.class) != null) { isDeclarative = true; } } } catch (IOException e) { LOGGER.log(Level.WARNING, "Error loading WorkflowRun for FlowNode: {0}", e); } declarativeRuns.put(execution, isDeclarative); } return declarativeRuns.get(execution); }
/** * Adds a new action. * Note: calls to {@link #getAllActions()} that happen before calls to this method may not see the update. * <strong>Note: this method will always modify the actions</strong> */ @SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public void addAction(@Nonnull Action a) { if(a==null) { throw new IllegalArgumentException("Action must be non-null"); } getActions().add(a); }
List<Action> current = getActions(); boolean found = false; for (Action a1 : current) { addAction(a);
/** * Gets all actions, transient or persistent. * {@link #getActions} is supplemented with anything contributed by {@link TransientActionFactory}. * @return an unmodifiable, possible empty list * @since 1.548 */ @Exported(name="actions") @Nonnull public final List<? extends Action> getAllActions() { List<Action> _actions = getActions(); boolean adding = false; for (TransientActionFactory<?> taf : TransientActionFactory.factoriesFor(getClass(), Action.class)) { Collection<? extends Action> additions = createFor(taf); if (!additions.isEmpty()) { if (!adding) { // need to make a copy adding = true; _actions = new ArrayList<>(_actions); } _actions.addAll(additions); } } return Collections.unmodifiableList(_actions); }
@Override public void addAction(Action a) { super.addAction(a); if (a instanceof RunAction) ((RunAction) a).onAttached(this); }
@Override protected SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder builder = super.makeSearchIndex() .add("console") .add("changes"); for (Action a : getActions()) { if(a.getIconFileName()!=null) builder.add(a.getUrlName()); } return builder; }
@Override public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) { Object result = super.getDynamic(token, req, rsp); if (result == null) // Next/Previous Build links on an action page (like /job/Abc/123/testReport) // will also point to same action (/job/Abc/124/testReport), but other builds // may not have the action.. tell browsers to redirect up to the build page. result = new RedirectUp(); return result; }