String[] c = context.getFullName().split("/"); String[] p = path.split("/"); if (name.size() == 0) { throw new IllegalArgumentException(String.format( "Illegal relative path '%s' within context '%s'", path, context.getFullName() ));
newValue.add("/" + newCanonicalName); } else { newValue.add(getRelativeNameFrom(newCanonicalName, context.getFullName()));
/** * Securely check for the existence of an item before trying to create one with the same name. * @param parent the folder where we are about to create/rename/move an item * @param newName the proposed new name * @param variant if not null, an existing item which we accept could be there * @throws IllegalArgumentException if there is already something there, which you were supposed to know about * @throws Failure if there is already something there but you should not be told details */ static void verifyItemDoesNotAlreadyExist(@Nonnull ItemGroup<?> parent, @Nonnull String newName, @CheckForNull Item variant) throws IllegalArgumentException, Failure { Item existing; try (ACLContext ctxt = ACL.as(ACL.SYSTEM)) { existing = parent.getItem(newName); } if (existing != null && existing != variant) { if (existing.hasPermission(Item.DISCOVER)) { String prefix = parent.getFullName(); throw new IllegalArgumentException((prefix.isEmpty() ? "" : prefix + "/") + newName + " already exists"); } else { // Cannot hide its existence, so at least be as vague as possible. throw new Failure(""); } } }
@Exported public final String getFullName() { String n = getParent().getFullName(); if(n.length()==0) return getName(); else return n+'/'+getName(); }
String prefix = rootItem.getParent().getFullName(); if (!prefix.isEmpty()) { prefix += '/';
/** * On some item groups, typically folders. * The grant applies to the folder itself as well as any (direct or indirect) children. */ public GrantOn onFolders(ItemGroup<?>... folders) { String[] paths = new String[folders.length]; for (int i = 0; i < folders.length; i++) { paths[i] = Pattern.quote(folders[i].getFullName()) + "(|/.+)"; } return onPaths(paths); }
public final String getFullName() { String n = getParent().getFullName(); if (n.length() == 0) { return getName(); } else { return n + '/' + getName(); } }
public final String getFullName() { String n = getParent().getFullName(); if(n.length()==0) return getName(); else return n+'/'+getName(); }
public final String getFullName() { String n = getParent().getFullName(); if(n.length()==0) return getName(); else return n+'/'+getName(); }
public final String getFullName() { String n = getParent().getFullName(); if(n.length()==0) return getName(); else return n+'/'+getName(); }
/** * Returns the full name of the {@link #getContext()}. * * @return the full name of the {@link #getContext()}. */ public String getContextFullName() { String n; if (context instanceof Item) { n = ((Item) context).getFullName(); } else if (context instanceof ItemGroup) { n = ((ItemGroup) context).getFullName(); } else if (context instanceof User) { n = "user/" + ((User) context).getId(); } else { n = ""; } return n; }
/** * Securely check for the existence of an item before trying to create one with the same name. * @param parent the folder where we are about to create/rename/move an item * @param newName the proposed new name * @param variant if not null, an existing item which we accept could be there * @throws IllegalArgumentException if there is already something there, which you were supposed to know about * @throws Failure if there is already something there but you should not be told details */ static void verifyItemDoesNotAlreadyExist(@Nonnull ItemGroup<?> parent, @Nonnull String newName, @CheckForNull Item variant) throws IllegalArgumentException, Failure { Item existing; try (ACLContext ctxt = ACL.as(ACL.SYSTEM)) { existing = parent.getItem(newName); } if (existing != null && existing != variant) { if (existing.hasPermission(Item.DISCOVER)) { String prefix = parent.getFullName(); throw new IllegalArgumentException((prefix.isEmpty() ? "" : prefix + "/") + newName + " already exists"); } else { // Cannot hide its existence, so at least be as vague as possible. throw new Failure(""); } } }
/** * Returns the full name of the {@link #getContext()}. * * @return the full name of the {@link #getContext()}. */ public String getContextFullName() { String n; if (context instanceof Item) { n = ((Item) context).getFullName(); } else if (context instanceof ItemGroup) { n = ((ItemGroup) context).getFullName(); } else if (context instanceof User) { n = "user/" + ((User) context).getId(); } else { n = ""; } return n; }
@Exported public final String getFullName() { String n = getParent().getFullName(); if(n.length()==0) return getName(); else return n+'/'+getName(); }
public void onRenamed(WorkflowJob pipeline, String oldName, String newName) { LOGGER.log(Level.FINE, "onRenamed({0}, {1}, {2})", new Object[]{pipeline, oldName, newName}); String oldFullName; ItemGroup parent = pipeline.getParent(); if (parent.equals(Jenkins.getInstance())) { oldFullName = oldName; } else { oldFullName = parent.getFullName() + "/" + oldName; } String newFullName = pipeline.getFullName(); globalPipelineMavenConfig.getDao().renameJob(oldFullName, newFullName); }
private static GitStatusContext getStatusContext(@Nonnull final Job job) { final String instanceUrl = StringUtils.stripEnd(Jenkins.getInstance().getRootUrl(), "/"); final String projectDisplayName = job.getParent().getFullName() + "/" + job.getDisplayName(); return new GitStatusContext(projectDisplayName, instanceUrl); }
/** * {@inheritDoc} */ @Override public void onChange(Saveable o, XmlFile file) { if (o instanceof Job) { Job<?, ?> item = (Job<?, ?>) o; LOGGER.log(Level.FINE, "Adding save action on " + item.getFullName() + " to the Activity Cache"); JobActivityCache activity = new JobActivityCache(Calendar.getInstance().getTimeInMillis(), item.getFullName()); if (hudson.model.User.current() != null) { activity.setCulprit(hudson.model.User.current().getId()); } else { activity.setCulprit(User.ANONYMOUS.getUserId()); } if (item.getParent().getFullName().length() > 0) { activity.setParent(item.getParent().getFullName()); } APIv2Plugin.getActivitiesCache().add(activity); } }
/** * Returns the {@link Item#getFullName()} or nearest approximation. * * @return the {@link Item#getFullName()} or nearest approximation. */ public final String getFullName() { String n; ModelObject context = getStore().getContext(); if (context instanceof Item) { n = ((Item) context).getFullName(); } else if (context instanceof ItemGroup) { n = ((ItemGroup) context).getFullName(); } else if (context instanceof User) { n = "user:" + ((User) context).getId(); } else { n = ""; } if (n.length() == 0) { return getUrlName(); } else { return n + '/' + getUrlName(); } }
/** * Returns the {@link Item#getFullName()} or nearest approximation. * * @return the {@link Item#getFullName()} or nearest approximation. */ public final String getFullName() { String n; ModelObject context = getStore().getContext(); if (context instanceof Item) { n = ((Item) context).getFullName(); } else if (context instanceof ItemGroup) { n = ((ItemGroup) context).getFullName(); } else if (context instanceof User) { n = "user:" + ((User) context).getId(); } else { n = ""; } if (n.length() == 0) { return getUrlName(); } else { return n + '/' + getUrlName(); } }
/** * Get a {@link BuildActivityCache} from the given {@link Run} * * @param r the {@link Run} to get the {@link BuildActivityCache} from * @return the {@link BuildActivityCache} */ private BuildActivityCache getBuildActivityCacheFromRun(Run r) { BuildActivityCache activity = new BuildActivityCache(r.getTimeInMillis(), r.getParent().getFullName(), r.getNumber()); if (!(r.getParent().getParent() instanceof Hudson)) { activity.setParent(r.getParent().getParent().getFullName()); } activity.setCulprit(BuildUtils.getCulpritFromRunnable(r)); return activity; }