/** * Work-around helper method to "fix" {@link Item} constructors that have on-disk side-effects and therefore * need {@link Item#getRootDir()} to work during the constructor. * @param project the {@link AbstractFolder}. * @param itemName the name that will be returned by {@link Item#getName()} when the item is constructed. This is * the second parameter of {@link AbstractItem#AbstractItem(ItemGroup, String)}. This one would be * the one with URL path segment escaping. * @param idealName the original name before whatever URL path segment escaping you applied * @return the {@link Trace} to keep track of when we can remove the memory of the creation process. Please * {@link Trace#close()} the trace after the item is created. */ @Nonnull public static final Trace beforeCreateItem(@Nonnull AbstractFolder<?> project, @Nonnull String itemName, @Nonnull String idealName) { final Trace trace = new Trace(project, itemName); synchronized (idealNames) { idealNames.put(trace, idealName); } return trace; }
p = new FreeStyleProject(this, encodedKid); } finally { trace.close();
p = new FreeStyleProject(this, encodedKid); } finally { trace.close();
p = new FreeStyleProject(this, encodedKid); } finally { trace.close();
/** * Work-around helper method to "fix" {@link Item} constructors that have on-disk side-effects and therefore * need {@link Item#getRootDir()} to work during the constructor. * @param project the {@link AbstractFolder}. * @param itemName the name that will be returned by {@link Item#getName()} when the item is constructed. This is * the second parameter of {@link AbstractItem#AbstractItem(ItemGroup, String)}. This one would be * the one with URL path segment escaping. * @param idealName the original name before whatever URL path segment escaping you applied * @return the {@link Trace} to keep track of when we can remove the memory of the creation process. Please * {@link Trace#close()} the trace after the item is created. */ @Nonnull public static final Trace beforeCreateItem(@Nonnull AbstractFolder<?> project, @Nonnull String itemName, @Nonnull String idealName) { final Trace trace = new Trace(project, itemName); synchronized (idealNames) { idealNames.put(trace, idealName); } return trace; }
/** * Looks up the {@link Item} to see if we stored the ideal name before invoking the constructor that is having * on-disk side-effects before the object has escaped {@link #beforeCreateItem(AbstractFolder, String, String)} * @param parent the parent within which the item is being created. * @param item the partially created item. * @return the ideal name of the item. */ @CheckForNull protected final String idealNameFromItem(@Nonnull P parent, @Nonnull I item) { String itemName = item.getName(); if (itemName == null) { return null; } synchronized (idealNames) { return idealNames.get(new Trace(parent, itemName)); } }
/** * Looks up the {@link Item} to see if we stored the ideal name before invoking the constructor that is having * on-disk side-effects before the object has escaped {@link #beforeCreateItem(AbstractFolder, String, String)} * @param parent the parent within which the item is being created. * @param item the partially created item. * @return the ideal name of the item. */ @CheckForNull protected final String idealNameFromItem(@Nonnull P parent, @Nonnull I item) { String itemName = item.getName(); if (itemName == null) { return null; } synchronized (idealNames) { return idealNames.get(new Trace(parent, itemName)); } }