private void dispatchViaSoyView(final HttpServletResponse httpServletResponse, final ActionResult ar, Option<ActionInfo.ViewInfo> viewInfo) throws ServletException, IOException { soyViewDispatcher.dispatch(httpServletResponse, ar, viewInfo.getOrError(ASSERTION_CANT_BE_NONE)); }
private AuthenticationContext getAuthenticationContext() { return getBeanForClass(AuthenticationContext.class) .getOrError(Suppliers.ofInstance( "Unable to find unique bean of type " + AuthenticationContext.class.getName() + " " + "in your Spring configuration" )); }
@VisibleForTesting Predicate<String> getAuthorizedSubjectPredicate() { Iterable<String> iterable = getAuthorizedSubjectsIterableFromFilterConfig() .orElse(getAuthorizedSubjectsIterableFromSpring()) .getOrError(Suppliers.ofInstance( "Missing bean with name " + AUTHORIZED_SUBJECTS_BEAN_NAME + " or servlet filter init-param with key " + AUTHORIZED_SUBJECTS_INIT_PARAM_KEY )); return Predicates.in(ImmutableList.copyOf(iterable)); }
private String renderCommentFields(final DescriptorToHtmlFunction descriptorToHtmlFunction, final CommentHelper commentHelper) { Iterable<CommentFieldRendererModuleDescriptor> descriptors = pluginAccessor.getEnabledModuleDescriptorsByClass(CommentFieldRendererModuleDescriptor.class); List<CommentFieldRendererModuleDescriptor> descriptorsOrderedByWeight = commentFieldRendererModuleDescriptorOrdering.sortedCopy(descriptors); // Complicated? Not really. We get all renders for which want to be displayed (according to the condition). // Then, transform all this to optional html (there might be no definition of field-view-resource, when we would get none). // Finally, pick the first non empty html. final Option<String> commentFieldToRender = getFirst(Options.filterNone(transform(filter(descriptorsOrderedByWeight, SafePluginPointAccess.safe(new Predicate<CommentFieldRendererModuleDescriptor>() { @Override public boolean apply(final CommentFieldRendererModuleDescriptor moduleDescriptor) { return moduleDescriptor.getCondition() == null || moduleDescriptor.getCondition().shouldDisplay(commentHelper.getContextParams()); } })), SafePluginPointAccess.safe(descriptorToHtmlFunction))), Option.<String>none()); return commentFieldToRender.getOrError(new Supplier<String>() { @Override public String get() { throw new IllegalStateException("There should be at least one comment field renderer, which can render the comments"); } }); }