protected void throwUnknownModuleType(String moduleTypeKey) throws ConnectModuleValidationException { throw new ConnectModuleValidationException( addon, new ConnectModuleMeta<ModuleBean>(moduleTypeKey, ModuleBean.class) { }, "No provider found for module type " + moduleTypeKey + " referenced in the descriptor", "connect.install.error.unknown.module", moduleTypeKey); }
protected void throwUnknownModuleType(String moduleTypeKey) throws ConnectModuleValidationException { throw new ConnectModuleValidationException( addon, new ConnectModuleMeta<ModuleBean>(moduleTypeKey, ModuleBean.class) { }, "No provider found for module type " + moduleTypeKey + " referenced in the descriptor", "connect.install.error.unknown.module", moduleTypeKey, addon.getKey()); }
private void rethrowAsModuleValidationException(Throwable cause, ShallowConnectAddonBean addon, ConnectModuleMeta<?> moduleMeta, String message, String i18nKey, Serializable... i18nParameters) throws ConnectModuleValidationException { ConnectModuleValidationException exception = new ConnectModuleValidationException( addon, moduleMeta, message, i18nKey, i18nParameters); exception.initCause(cause); throw exception; } }
private void rethrowAsModuleValidationException(Throwable cause, ShallowConnectAddonBean addon, ConnectModuleMeta<?> moduleMeta, String message, String i18nKey, Serializable... i18nParameters) throws ConnectModuleValidationException { ConnectModuleValidationException exception = new ConnectModuleValidationException( addon, moduleMeta, message, i18nKey, i18nParameters); exception.initCause(cause); throw exception; } }
/** * Asserts that the module type accepts multiple modules. * * @param moduleMeta the metadata for the module being deserialized * @param descriptor the add-on descriptor (without the module list) * @throws ConnectModuleValidationException if the assertion fails */ private void assertMultipleModulesAllowed(ConnectModuleMeta<?> moduleMeta, ShallowConnectAddonBean descriptor) throws ConnectModuleValidationException { if (!moduleMeta.multipleModulesAllowed()) { throw new ConnectModuleValidationException(descriptor, moduleMeta, "Modules should be provided as a JSON array of objects.", null, null); } }
/** * Asserts that the module type only accepts a single module. * * @param moduleMeta the metadata for the module being deserialized * @param descriptor the add-on descriptor (without the module list) * @throws ConnectModuleValidationException if the assertion fails */ private void assertMultipleModulesNotAllowed(ConnectModuleMeta<?> moduleMeta, ShallowConnectAddonBean descriptor) throws ConnectModuleValidationException { if (moduleMeta.multipleModulesAllowed()) { throw new ConnectModuleValidationException(descriptor, moduleMeta, "A single module should be provided as a JSON object.", null, null); } } }
/** * Asserts that the module type accepts multiple modules. * * @param moduleMeta the metadata for the module being deserialized * @param descriptor the add-on descriptor (without the module list) * @throws ConnectModuleValidationException if the assertion fails */ private void assertMultipleModulesAllowed(ConnectModuleMeta<?> moduleMeta, ShallowConnectAddonBean descriptor) throws ConnectModuleValidationException { if (!moduleMeta.multipleModulesAllowed()) { throw new ConnectModuleValidationException(descriptor, moduleMeta, "Modules should be provided as a JSON array of objects.", null, null); } }
/** * Asserts that the module type only accepts a single module. * * @param moduleMeta the metadata for the module being deserialized * @param descriptor the add-on descriptor (without the module list) * @throws ConnectModuleValidationException if the assertion fails */ private void assertMultipleModulesNotAllowed(ConnectModuleMeta<?> moduleMeta, ShallowConnectAddonBean descriptor) throws ConnectModuleValidationException { if (moduleMeta.multipleModulesAllowed()) { throw new ConnectModuleValidationException(descriptor, moduleMeta, "A single module should be provided as a JSON object.", null, null); } } }
@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()); } } }
/** * Asserts that the module type accepts multiple modules. * * @param descriptor the add-on descriptor (without the module list) * @throws ConnectModuleValidationException if the assertion fails */ private void assertMultipleModulesAllowed(ShallowConnectAddonBean descriptor) throws ConnectModuleValidationException { if (!getMeta().multipleModulesAllowed()) { throw new ConnectModuleValidationException(descriptor, getMeta(), "Modules should be provided as a JSON array of objects.", null, null); } }
/** * Asserts that the module type only accepts a single module. * * @param descriptor the add-on descriptor (without the module list) * @throws ConnectModuleValidationException if the assertion fails */ private void assertMultipleModulesNotAllowed(ShallowConnectAddonBean descriptor) throws ConnectModuleValidationException { if (getMeta().multipleModulesAllowed()) { throw new ConnectModuleValidationException(descriptor, getMeta(), "A single module should be provided as a JSON object.", null, null); } } }
private void assertValidPageCondition(ShallowConnectAddonBean descriptor, SingleConditionBean conditionBean, List<ConnectConditionClassResolver> conditionClassResolvers) throws ConnectModuleValidationException { if (!isRemoteCondition(conditionBean.getCondition()) && !isContextFreeCondition(conditionBean, conditionClassResolvers)) { String exceptionMessage = String.format("The add-on includes a Page Module with an unsupported condition (%s)", conditionBean.getCondition()); throw new ConnectModuleValidationException(descriptor, getMeta(), exceptionMessage, "connect.install.error.page.with.invalid.condition", conditionBean.getCondition()); } }
private void assertValidPageCondition(ShallowConnectAddonBean descriptor, SingleConditionBean conditionBean) throws ConnectModuleValidationException { if (!isRemoteCondition(conditionBean.getCondition()) && !isContextFreeCondition(conditionBean)) { String exceptionMessage = String.format("The add-on includes a Page Module with an unsupported condition (%s)", conditionBean.getCondition()); throw new ConnectModuleValidationException(descriptor, getMeta(), exceptionMessage, "connect.install.error.page.with.invalid.condition", conditionBean.getCondition()); } }
private void assertValidPageCondition(ShallowConnectAddonBean descriptor, SingleConditionBean conditionBean) throws ConnectModuleValidationException { if (!isRemoteCondition(conditionBean.getCondition()) && !isContextFreeCondition(conditionBean)) { String exceptionMessage = String.format("The add-on includes a Page Module with an unsupported condition (%s)", conditionBean.getCondition()); throw new ConnectModuleValidationException(descriptor, getMeta(), exceptionMessage, "connect.install.error.page.with.invalid.condition", conditionBean.getCondition()); } }