/** * This method was removed in Connect 1.2.5 (replaced by the below), re-added in 1.2.6 * to preserve binary compatibility. Can be removed as soon as JSD 1000.612.0 is in prod. * * @deprecated use {@link #getKey(ShallowConnectAddonBean)} instead. */ @Deprecated public String getKey(ConnectAddonBean addon) { return getKey((ShallowConnectAddonBean) addon); }
public RequiredKeyBeanBuilder(RequiredKeyBean defaultBean) { super(defaultBean); this.key = defaultBean.getRawKey(); }
@Override public B build() { return (B) new RequiredKeyBean(this); } }
@Override public int hashCode() { return new HashCodeBuilder(13, 61) .appendSuper(super.hashCode()) .append(url) .append(options) .build(); }
@Override public boolean equals(Object otherObj) { if (otherObj == this) { return true; } if (!(otherObj instanceof DialogModuleBean && super.equals(otherObj))) { return false; } DialogModuleBean other = (DialogModuleBean) otherObj; return new EqualsBuilder() .append(getUrl(), other.getUrl()) .append(options, other.options) .isEquals(); }
@Override public int hashCode() { return new HashCodeBuilder(13, 61) .appendSuper(super.hashCode()) .append(url) .append(options) .build(); }
@Override public boolean equals(Object otherObj) { if (otherObj == this) { return true; } if (!(otherObj instanceof DialogModuleBean && super.equals(otherObj))) { return false; } DialogModuleBean other = (DialogModuleBean) otherObj; return new EqualsBuilder() .append(getUrl(), other.getUrl()) .append(options, other.options) .isEquals(); }
public RequiredKeyBeanBuilder(RequiredKeyBean defaultBean) { super(defaultBean); this.key = defaultBean.getRawKey(); }
private static Map<String, String> createKeyToQualifiedKeyMap(ConnectAddonBean addon, List<ModuleBean> modules) { List<RequiredKeyBean> requiredKeyBeans = modules.stream() .filter(module -> module instanceof RequiredKeyBean) .map(RequiredKeyBean.class::cast) .collect(Collectors.toList()); ImmutableMap<String, RequiredKeyBean> rawKeyMap = Maps.uniqueIndex(requiredKeyBeans, RequiredKeyBean::getRawKey); return Maps.transformValues(rawKeyMap, requiredKeyBean -> requiredKeyBean.getKey(addon)); } }
@Override public B build() { return (B) new RequiredKeyBean(this); } }
/** * Get a module bean, restricting which type it is allowed to be. * * @param moduleKey the module key * @param allowedBeanTypes allowed module bean types * @return Module bean */ public Optional<? extends ModuleBean> getValidModuleOfType(String moduleKey, Set<Class<? extends ModuleBean>> allowedBeanTypes, Consumer<Exception> exceptionHandler) { return allowedBeanTypes.stream() .flatMap(type -> getValidModuleListOfClass(type, exceptionHandler) .stream()) .filter(moduleBean -> (moduleBean instanceof RequiredKeyBean) && ((RequiredKeyBean) moduleBean).getRawKey().equals(moduleKey)) .findFirst(); }
private static Map<String, String> createKeyToQualifiedKeyMap(ConnectAddonBean addon, List<ModuleBean> modules) { List<RequiredKeyBean> requiredKeyBeans = modules.stream() .filter(module -> module instanceof RequiredKeyBean) .map(RequiredKeyBean.class::cast) .collect(Collectors.toList()); ImmutableMap<String, RequiredKeyBean> rawKeyMap = Maps.uniqueIndex(requiredKeyBeans, RequiredKeyBean::getRawKey); return Maps.transformValues(rawKeyMap, requiredKeyBean -> requiredKeyBean.getKey(addon)); } }
/** * Get a module bean, restricting which type it is allowed to be. * * @param moduleKey the module key * @param allowedBeanTypes allowed module bean types * @return Module bean */ public Optional<? extends ModuleBean> getValidModuleOfType(String moduleKey, Set<Class<? extends ModuleBean>> allowedBeanTypes, Consumer<Exception> exceptionHandler) { return allowedBeanTypes.stream() .flatMap(type -> getValidModuleListOfClass(type, exceptionHandler) .stream()) .filter(moduleBean -> (moduleBean instanceof RequiredKeyBean) && ((RequiredKeyBean) moduleBean).getRawKey().equals(moduleKey)) .findFirst(); }
@Override public void validateModules(ConnectAddonBean addon, Map<String, List<ModuleBean>> validModulesByDescriptorKey) throws ConnectModuleValidationException { final Map<String, List<DescriptorKeyAndBean>> descriptorKeyAndBeanByRawKey = validModulesByDescriptorKey.entrySet().stream() .flatMap(e -> e.getValue().stream().filter(moduleBean -> moduleBean instanceof RequiredKeyBean).map(moduleBean -> new DescriptorKeyAndBean(e.getKey(), (RequiredKeyBean) moduleBean))) .collect(Collectors.groupingBy(e -> e.getModuleBean().getRawKey())); final Map<String, List<DescriptorKeyAndBean>> duplicateDescriptorKeyAndBeans = descriptorKeyAndBeanByRawKey.entrySet().stream() .filter(e -> e.getValue().size() > 1) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); if(!duplicateDescriptorKeyAndBeans.isEmpty()) { final List<DescriptorKeyAndBean> firstDuplicateKeyAndBean = Iterables.getFirst(duplicateDescriptorKeyAndBeans.values(), null); final DescriptorKeyAndBean firstDuplicate = Iterables.getFirst(firstDuplicateKeyAndBean, null); final String firstDuplicateDescriptorKey = firstDuplicate.getDescriptorKey(); final ConnectModuleMeta<? extends ModuleBean> firstModuleMeta = pluginAccessor.getEnabledModuleDescriptorsByClass(ConnectModuleProviderModuleDescriptor.class).stream() .map(ConnectModuleProviderModuleDescriptor::getModule) .map(ConnectModuleProvider::getMeta) .filter(e -> e.getDescriptorKey().equals(firstDuplicateDescriptorKey)) .findFirst().orElseThrow(() -> new IllegalArgumentException("There is no Atlassian Connect module with the descriptor key: " + firstDuplicateDescriptorKey)); final Set<String> duplicateKeys = duplicateDescriptorKeyAndBeans.keySet(); final String errorMessage = "Could not install add-on. Detected duplicate add-on module keys in '" + addon.getKey() + "'. Duplicate keys: " + duplicateKeys; if(DUPLICATES_ALLOWED_ADDON_RATCHET.contains(addon.getKey())) { log.error(errorMessage); } else { throw new ConnectModuleValidationException(addon, firstModuleMeta, errorMessage, "connect.install.error.duplicate.module.keys", addon.getKey(), duplicateKeys.toString()); } } }