/** * Sets the ownership information. * * @param folder Folder to be modified * @param descr A description to be set. Use null to drop settings. * @throws IOException */ public static void setOwnership( @Nonnull AbstractFolder<?> folder, @CheckForNull OwnershipDescription descr) throws IOException { FolderOwnershipProperty prop = getOwnerProperty(folder); if (prop == null) { prop = new FolderOwnershipProperty(descr); folder.addProperty(prop); } else { prop.setOwnershipDescription(descr); } }
@Override public OwnershipInfo getOwnershipInfo(AbstractFolder<?> item) { if (item == null) { // Handle renames, etc. return OwnershipInfo.DISABLED_INFO; } // Retrieve Ownership from the Folder property FolderOwnershipProperty prop = getOwnerProperty(item); if (prop != null) { OwnershipDescription d = prop.getOwnership(); if (d.isOwnershipEnabled()) { return new OwnershipInfo(prop.getOwnership(), new FolderOwnershipDescriptionSource(item)); } } // We go to upper items in order to get the ownership description if (!OwnershipPluginConfiguration.get() .getInheritanceOptions() .isBlockInheritanceFromItemGroups()) { ItemGroup parent = item.getParent(); AbstractOwnershipHelper<ItemGroup> located = OwnershipHelperLocator.locate(parent); while (located != null) { OwnershipInfo fromParent = located.getOwnershipInfo(parent); if (fromParent.getDescription().isOwnershipEnabled()) { return fromParent; } if (parent instanceof Item) { Item parentItem = (Item) parent; parent = parentItem.getParent(); located = OwnershipHelperLocator.locate(parent); } else { located = null; } } } return OwnershipInfo.DISABLED_INFO; }
@Override public String getItemURL(AbstractFolder<?> item) { return item.getUrl(); }
@Override public String getItemDisplayName(AbstractFolder<?> item) { return item.getDisplayName(); }
/** * Gets OwnerNodeProperty from job if possible. * * @param folder Folder * @return OwnerNodeProperty or null */ @CheckForNull public static FolderOwnershipProperty getOwnerProperty(@Nonnull AbstractFolder<?> folder) { FolderOwnershipProperty prop = folder.getProperties().get(FolderOwnershipProperty.class); return prop != null ? prop : null; }