private Iterable<WebPanelModuleDescriptor> getDisplayableWebPanelDescriptors(final Map<String, Object> context) { return Iterables.filter(SafePluginPointAccess.call(new Callable<List<WebPanelModuleDescriptor>>() { @Override public List<WebPanelModuleDescriptor> call() throws Exception { return webInterfaceManager.getDisplayableWebPanelDescriptors(TAB_PANELS_LOCATION, context); } }).getOrElse(Collections.<WebPanelModuleDescriptor>emptyList()), Predicates.notNull()); } }
private String getSupplierValueOrHtmlErrorMessage(final Callable<String> callable) { final Supplier<String> errorMessageSupplier = new Supplier<String>() { @Override public String get() { return getHtmlErrorMessage(); } }; return SafePluginPointAccess.call(callable).getOrElse(errorMessageSupplier); }
@Override public String getUserCountDescription(final Option<Integer> count) { final Supplier<String> unlimited = () -> String.format("Unlimited %s users", key); return count.map(c -> String.format("%d %s users", c, key)).getOrElse(unlimited); }
public List<QueryLiteral> getValues(final QueryCreationContext queryCreationContext, final FunctionOperand operand, final TerminalClause terminalClause) { return SafePluginPointAccess.call(new Callable<List<QueryLiteral>>() { @Override public List<QueryLiteral> call() throws Exception { return jqlFunction.getValues(queryCreationContext, operand, terminalClause); } }).getOrElse(Collections.<QueryLiteral>emptyList()); }
public boolean isList() { return SafePluginPointAccess.call(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return jqlFunction.isList(); } }).getOrElse(false); }
@Nonnull public List<SimpleLinkSection> getSectionsForLocation(@Nonnull final String location, final ApplicationUser remoteUser, @Nonnull final JiraHelper jiraHelper) { final Iterable<WebSection> sections = SafePluginPointAccess.call(() -> webInterfaceManager.getDisplayableWebSections(location, makeContext(remoteUser, jiraHelper))).getOrElse(Collections.emptyList()); final List<SimpleLinkSection> returnSections = new ArrayList<SimpleLinkSection>(Iterables.size(sections)); for (final WebSection section : sections) { returnSections.add(convertWebSectionToSimpleLinkSection(section)); } return returnSections; }
@Nonnull @Override public Set<Group> getDefaultGroups(@Nonnull final ApplicationKey key) { notNull("key", key); return getRole(key).map(ApplicationRole::getDefaultGroups).getOrElse(ImmutableSet.of()); }
/** * Generate a localised message for this exception. * @param localisedMessages Internationalisation helper that can provide localised messages for given codes. * @return a localised message for this exception */ public final String generateMessage(final I18nHelper localisedMessages) { Option<String> generatedMessage = doGenerateMessage(localisedMessages); return generatedMessage.getOrElse(this.getMessage()); }
@Override public Clause visit(final TerminalClause clause) { return queryRegistry.getClauseQueryFactory(queryCreationContext, clause).map(new Function<WorklogClauseQueryFactory, Clause>() { @Override public Clause apply(final WorklogClauseQueryFactory input) { return toIssueSet(input.getWorklogQuery(queryCreationContext, clause)); } }).getOrElse(clause); }
@Nonnull public List<SimpleLink> getLinksForSectionIgnoreConditions(@Nonnull final String section, final ApplicationUser remoteUser, @Nonnull final JiraHelper jiraHelper) { return SafePluginPointAccess.call(() -> getLinks(section, webInterfaceManager.getWebItems(section, makeContext(remoteUser, jiraHelper)), remoteUser, jiraHelper, false)).getOrElse(Collections.emptyList()); }
@Override public void apply(final Comment comment) { commentManager.update(comment, validationResult.getCommentProperties().getOrElse(Collections.EMPTY_MAP), dispatchEvent); } });
@Override public String getUserCountDescription(final Option<Integer> count) { return ctx.getI18nHelper().getText("jira.core.user.count", count.getOrElse(-1)); }
public boolean shouldDisplay(final Map<String, Object> context) { final JiraHelper jiraHelper = (JiraHelper) context.get(JiraWebInterfaceManager.CONTEXT_KEY_HELPER); final ApplicationUser appUser = getApplicationUser(context); return SafePluginPointAccess.call(() -> shouldDisplay(appUser, jiraHelper)).getOrElse(false); }
private String renderPanel(final String location, final ImmutableMap<String, Object> context) { return SafePluginPointAccess.call(() -> { final List<WebPanel> panels = dynamicWebInterfaceManager.getDisplayableWebPanels(location, ImmutableMap.of()); return SafePluginPointAccess.to() .modules(panels, (PluginPointFunction<ModuleDescriptor<WebPanel>, WebPanel, String>) (descriptor, webPanel) -> webPanel.getHtml(context)) .stream().collect(Collectors.joining()); }).getOrElse(""); } }
private Either<IOException, Option<Properties>> tryLoadProperties(final Supplier<Option<InputStream>> resourceSupplier) { final Option<InputStream> streamOption = resourceSupplier.get(); final Supplier<Either<IOException, Option<Properties>>> emptyPropertiesSupplier = () -> Either.<IOException, Option<Properties>>right(Option.none()); return streamOption.map(this::tryLoadProperties). getOrElse(emptyPropertiesSupplier); }
public static String getSchemaName() { // DatabaseConfigurationManager.getDatabaseConfiguration() will throw a RuntimeException if you call it before // we have a configured DB config (i.e on a fresh install before DB Setup). // Once it actually returns successfully, the schema name will not change. if (schemaName == null) { schemaName = Option.option(ComponentAccessor.getComponent(DatabaseConfigurationService.class).getSchemaName()); } return schemaName.getOrElse(""); } }
private Map<Object, Object> getSalDarkFeatures() { final String salDarkFeaturesProperty = jiraSystemProperties.getProperty( DARKFEATURES_PROPERTIES_FILE_PROPERTY, DARKFEATURES_PROPERTIES_FILE_PROPERTY_DEFAULT); final Supplier<Properties> emptyProperties = Properties::new; return tryLoadProperties(() -> resourceLoader.getResourceAsStream(salDarkFeaturesProperty)) .fold(ex -> emptyMap(), (Option<Properties> propertiesOption) -> propertiesOption.getOrElse(emptyProperties)); }
private String getDefaultGroupName(final ApplicationKey applicationKey) { return toGroupName(applicationManager.getApplication(applicationKey).map(Application::getDefaultGroup) .getOrElse((Supplier<String>) () -> String.format("%s-users", applicationKey.value()))); }
public Hint get(final WebItem input) { final Option<String> label = option(input.getLabel()); if(label.isEmpty()) { log.warn("Hint web item with key '" + input.getCompleteKey() + "' does not define a label"); } return new HintImpl(label.getOrElse(""), input.getTitle()); } });