/** * {@inheritDoc} */ @Override public void checkPermission(@Nonnull Permission permission) throws AccessDeniedException { getACL().checkPermission(permission); }
/** * {@inheritDoc} */ @Override public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { return getChildrenContextMenu(""); }
/** * {@inheritDoc} */ @Override public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { return getContextMenu(""); }
/** * 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(); } }
/** * Exposes {@link CredentialsStore#isDomainsModifiable()} for Jelly. * * @return {@link CredentialsStore#isDomainsModifiable()}. */ public boolean isDomainsModifiable() { return getStore().isDomainsModifiable(); }
/** * {@inheritDoc} */ // In the general case we would implement ModelObjectWithChildren as the child actions could be viewed as children // but in this case we expose them in the sidebar, so they are more correctly part of the context menu. @Override public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { ContextMenu menu = new ContextMenu(); for (CredentialsStoreAction action : getStoreActions()) { ContextMenuIconUtils.addMenuItem( menu, "store", action, action.getContextMenu(ContextMenuIconUtils.buildUrl("store", action.getUrlName())) ); } return menu; }
/** * Creates the context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); if (getStore().isDomainsModifiable() && getStore().hasPermission(MANAGE_DOMAINS)) { menu.add(ContextMenuIconUtils.buildUrl(prefix, "newDomain"), getMenuItemIconUrlByClassSpec("icon-credentials-new-domain icon-md"), Messages.CredentialsStoreAction_AddDomainAction() ); } for (Action action : getActions()) { ContextMenuIconUtils.addMenuItem(menu, prefix, action); } return menu.items.isEmpty() ? null : menu; }
/** * Returns the {@link Item#getFullDisplayName()} or nearest approximation. * * @return the {@link Item#getFullDisplayName()} or nearest approximation. */ public final String getFullDisplayName() { String n; ModelObject context = getStore().getContext(); if (context instanceof Item) { n = ((Item) context).getFullDisplayName(); } else if (context instanceof ItemGroup) { n = ((ItemGroup) context).getFullDisplayName(); } else if (context instanceof User) { n = Messages.CredentialsStoreAction_UserDisplayName(((User) context).getDisplayName()); } else { // TODO switch to Jenkins.getInstance() once 2.0+ is the baseline n = Jenkins.getActiveInstance().getFullDisplayName(); } if (n.length() == 0) { return getDisplayName(); } else { return n + " \u00BB " + getDisplayName(); } }
/** * Exposes the {@link #getLocalStores()} for the XML API. * * @return the {@link #getLocalStores()} for the XML API. * @since 2.1.0 */ @NonNull @SuppressWarnings("unused") // Stapler XML/JSON API @Exported(name = "stores") public Map<String,CredentialsStoreAction> getStoreActionsMap() { Map<String,CredentialsStoreAction> result = new TreeMap<String, CredentialsStoreAction>(); for (CredentialsStoreAction a: getStoreActions()) { result.put(a.getUrlName(), a); } return result; }
/** * Gets the named {@link DomainWrapper}. * * @param name the name. * @return the named {@link DomainWrapper}. */ @CheckForNull public DomainWrapper getDomain(String name) { return getDomains().get(name); }
/** * Return the full name. * * @return the full name. */ @Exported public final String getFullName() { String n = getParent().getFullName(); if (n.length() == 0) { return getUrlName(); } else { return n + '/' + getUrlName(); } }
/** * Return the full display name. * * @return the full display name. */ @Exported public final String getFullDisplayName() { String n = getParent().getFullDisplayName(); if (n.length() == 0) { return getDisplayName(); } else { return n + " \u00BB " + getDisplayName(); } }
/** * Exposes the {@link #getActions()} for Stapler. * * @param token the name of the action. * @return the {@link Action} or {@code null} * @since 2.0 */ @CheckForNull @SuppressWarnings("unused") // stapler binding public Object getDynamic(String token) { for (Action a : getActions()) { String url = a.getUrlName(); if (url == null) { continue; } if (url.equals(token)) { return a; } } return null; }
/** * {@inheritDoc} */ @Nonnull @Override public ACL getACL() { return getStore().getACL(); }
/** * 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(); } }
/** * {@inheritDoc} */ // In the general case we would implement ModelObjectWithChildren as the child actions could be viewed as children // but in this case we expose them in the sidebar, so they are more correctly part of the context menu. @Override public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { ContextMenu menu = new ContextMenu(); for (CredentialsStoreAction action : getStoreActions()) { ContextMenuIconUtils.addMenuItem( menu, "store", action, action.getContextMenu(ContextMenuIconUtils.buildUrl("store", action.getUrlName())) ); } return menu; }
/** * Creates the context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); if (getStore().isDomainsModifiable() && getStore().hasPermission(MANAGE_DOMAINS)) { menu.add(ContextMenuIconUtils.buildUrl(prefix, "newDomain"), getMenuItemIconUrlByClassSpec("icon-credentials-new-domain icon-md"), Messages.CredentialsStoreAction_AddDomainAction() ); } for (Action action : getActions()) { ContextMenuIconUtils.addMenuItem(menu, prefix, action); } return menu.items.isEmpty() ? null : menu; }
/** * Returns the {@link Item#getFullDisplayName()} or nearest approximation. * * @return the {@link Item#getFullDisplayName()} or nearest approximation. */ public final String getFullDisplayName() { String n; ModelObject context = getStore().getContext(); if (context instanceof Item) { n = ((Item) context).getFullDisplayName(); } else if (context instanceof ItemGroup) { n = ((ItemGroup) context).getFullDisplayName(); } else if (context instanceof User) { n = Messages.CredentialsStoreAction_UserDisplayName(((User) context).getDisplayName()); } else { // TODO switch to Jenkins.getInstance() once 2.0+ is the baseline n = Jenkins.getActiveInstance().getFullDisplayName(); } if (n.length() == 0) { return getDisplayName(); } else { return n + " \u00BB " + getDisplayName(); } }
/** * Exposes the {@link #getLocalStores()} for the XML API. * * @return the {@link #getLocalStores()} for the XML API. * @since 2.1.0 */ @NonNull @SuppressWarnings("unused") // Stapler XML/JSON API @Exported(name = "stores") public Map<String,CredentialsStoreAction> getStoreActionsMap() { Map<String,CredentialsStoreAction> result = new TreeMap<String, CredentialsStoreAction>(); for (CredentialsStoreAction a: getStoreActions()) { result.put(a.getUrlName(), a); } return result; }
/** * Gets the named {@link DomainWrapper}. * * @param name the name. * @return the named {@link DomainWrapper}. */ @CheckForNull public DomainWrapper getDomain(String name) { return getDomains().get(name); }