private String doGetPreviewHtml(final String rendererType, final String unrenderedMarkup, final IssueRenderContext renderContext) { // The issueRenderContext allows us to resolve links to attached files and is also used by the wiki renderer, if // the issue is null then it is probably the case that we are on the CreateIssue screen and therefore we will // not have any attachments. The worst that will happen rendering wiki markup without an issue context is that some links // will not render. JRA-11464(JIRA), JST-763(JIRA Studio). final String result = rendererManager.getRenderedContent(rendererType, unrenderedMarkup, renderContext); return (StringUtils.isBlank(result)) ? RenderersResource.NBSP : result; }
public String getDescription(String fieldDescription) { String description = fieldDescription; if (featureManager.isOnDemand()) { description = rendererManager.getRenderedContent(AtlassianWikiRenderer.RENDERER_TYPE, fieldDescription, null); } return description; } }
private String getActionHtml(Comment comment) { return rendererManager.getRenderedContent(new CommentFieldRenderContext(comment)); }
private Object getRendererCustomFieldValue(FieldLayoutItem fieldLayoutItem, Issue issue, Map displayParams) { Object customFieldValue = issue.getCustomFieldValue(this); if (isRenderable() && displayParams.get("excel_view") == null) { String renderedContent = rendererManager.getRenderedContent(fieldLayoutItem, issue); if (StringUtils.isNotBlank(renderedContent)) { // JRA-12479 - probably the custom field is in value creation process customFieldValue = renderedContent; } } return customFieldValue; }
public String getViewHtml(FieldLayoutItem fieldLayoutItem, Action action, Issue issue, Map displayParameters) { Map velocityParams = getVelocityParams(fieldLayoutItem, action, issue, displayParameters); if (isRenderable()) { velocityParams.put("value", rendererManager.getRenderedContent(fieldLayoutItem, issue)); } else { velocityParams.put("value", getValueFromIssue(issue)); } return getViewHtml(velocityParams); }
@Override public void send() throws MailException { String format = recipient.getFormat(); String bodyTemplatePath = "templates/email/" + format + "/issuementioned.vm"; String comment = (String) context.get("comment"); String content = rendererManager.getRenderedContent( AtlassianWikiRenderer.RENDERER_TYPE, comment, issueRenderContext); context.put("htmlComment", content); MailQueueItem item = new MailServiceQueueItemBuilder(from, recipient, subjectTemplatePath, bodyTemplatePath, context).buildQueueItemUsingProjectEmailAsReplyTo(); mailQueue.addItem(item); }
private Object getRendererCustomFieldValue(FieldLayoutItem fieldLayoutItem, Issue issue, Object value) { Object customFieldValue; if (isRenderable() && value instanceof String) { String rendererType = (fieldLayoutItem != null) ? fieldLayoutItem.getRendererType() : null; customFieldValue = rendererManager.getRenderedContent(rendererType, (String) value, issue.getIssueRenderContext()); } else { customFieldValue = value; } return customFieldValue; }
public String render(String text, boolean linkCruKeys) { if (linkCruKeys) { text = CrucibleRenderer.linkCrucibleKeys(text, fishEyeConfig.getCrucibleProjectToUrlMappings()); } IssueRenderContext renderContext = resolveContext(text); return rendererManager.getRenderedContent(MESSAGE_RENDERER, text, renderContext); }
/** * Returns the view HTML for this renderable application property. * * @return a String containing the view HTML */ @Override public final String getViewHtml() { if (isOnDemand()) { return rendererManager.getRenderedContent(AtlassianWikiRenderer.RENDERER_TYPE, getValue(), null); } // no OnDemand == no encoding return getValue(); }
protected void populateVelocityParams(Map params) { params.put("action", this); params.put("worklog", this.getWorklog()); params.put("content", worklog.getComment()); params.put("userformats", userFormats); try { final FieldLayoutItem fieldLayoutItem = fieldLayoutManager.getFieldLayout(issue).getFieldLayoutItem(IssueFieldConstants.WORKLOG); if (fieldLayoutItem != null) { params.put("content", rendererManager.getRenderedContent(fieldLayoutItem.getRendererType(), worklog.getComment(), issue.getIssueRenderContext())); } } catch (DataAccessException e) { log.error(e.getMessage(), e); } }
@Override public String call() { CustomField customField = fieldConfig.getCustomField(); Object value = customField.getCustomFieldType().getDefaultValue(fieldConfig); if (customField.isRenderable()) { String rendererType = (fieldLayoutItem != null) ? fieldLayoutItem.getRendererType() : null; return rendererManager.getRenderedContent(rendererType, (String) value, null); } return getViewHtmlByValue(fieldLayoutItem, value, customField, null, TEMPLATE_NAME_VIEW, null); } });
@Override public FieldJsonRepresentation getJsonFromIssue(Issue issue, boolean renderedVersionRequired, FieldLayoutItem fieldLayoutItem) { FieldJsonRepresentation fieldJsonRepresentation = new FieldJsonRepresentation(new JsonData(getValueFromIssue(issue))); if (renderedVersionRequired && isRenderable() && fieldLayoutItem != null && org.apache.commons.lang.StringUtils.isNotBlank(fieldLayoutItem.getRendererType())) { fieldJsonRepresentation.setRenderedData(new JsonData(rendererManager.getRenderedContent(fieldLayoutItem, issue))); } return fieldJsonRepresentation; } }
@Override public FieldJsonRepresentation getJsonFromIssue(CustomField field, Issue issue, boolean renderedVersionRequested, @Nullable FieldLayoutItem fieldLayoutItem) { String value = getValueFromIssue(field, issue); FieldJsonRepresentation bean = new FieldJsonRepresentation(new JsonData(value)); if (field.isRenderable() && renderedVersionRequested && fieldLayoutItem != null) { final String content = ComponentAccessor.getComponent(RendererManager.class).getRenderedContent(fieldLayoutItem, issue); bean.setRenderedData(new JsonData(content)); } return bean; }
@Override public FieldJsonRepresentation getJsonFromIssue(CustomField field, Issue issue, boolean renderedVersionRequested, @Nullable FieldLayoutItem fieldLayoutItem) { Object value = getValueFromIssue(field, issue); FieldJsonRepresentation bean = new FieldJsonRepresentation(new JsonData(value)); if (field.isRenderable() && renderedVersionRequested && fieldLayoutItem != null) { final String content = ComponentAccessor.getComponent(RendererManager.class).getRenderedContent(fieldLayoutItem, issue); bean.setRenderedData(new JsonData(content)); } return bean; } }
@Override public String call() { final Map<String, Object> combinedMap = getCombinedMap(field.getCustomFieldType().getVelocityParameters(issue, field, fieldLayoutItem), MapBuilder.build(VELOCITY_VALUE_PARAM, field.getValue(issue))); if (field.isRenderable() && !raw) { String rendererType = (fieldLayoutItem != null) ? fieldLayoutItem.getRendererType() : null; combinedMap.put("renderedValue", rendererManager.getRenderedContent(rendererType, (String) field.getValue(issue), issue.getIssueRenderContext())); } return getHtml(TEMPLATE_NAME_XML, combinedMap); } });
@Override public String getFieldName() { //xss is allowed on BTF until 6.0 so we use wiki renderer to allow simple markup only in OD if (featureManager.isOnDemand()) { final IssueRenderContext renderContext = new IssueRenderContext(null); renderContext.addParam(IssueRenderContext.INLINE_PARAM, Boolean.TRUE); return rendererManager.getRenderedContent(AtlassianWikiRenderer.RENDERER_TYPE, getName(), renderContext); } else { return TextUtils.htmlEncode(getName()); } }
/** * Retrieves the html formatted description. * <p/> * A simple string (with linked bug keys displayed) is returned if a rendered version cannot be generated. * * @return String the html formatted description. */ public String getHtmlDescription() { // Try to generate rendered values for description try { FieldLayout fieldLayout = fieldLayoutManager.getFieldLayout(issue); FieldLayoutItem fieldLayoutItem = fieldLayout.getFieldLayoutItem(IssueFieldConstants.DESCRIPTION); String rendererType = (fieldLayoutItem != null) ? fieldLayoutItem.getRendererType() : null; String renderedContent = rendererManager.getRenderedContent(rendererType, issue.getDescription(), issue.getIssueRenderContext()); return renderedContent.replaceAll("<p>", "<p style='margin-top:0;margin-bottom:10px;'>"); } catch (Exception e) { log.warn("Unable to produce rendered version of the description for the issue " + issue.getKey(), e); return JiraKeyUtils.linkBugKeys(issue.getDescription()); } }
public Html renderIssueFieldValue(Issue issue, String fieldId, String value) { FieldLayoutItem fieldLayoutItem = fieldLayoutManager.getFieldLayout(issue.getProjectObject(), issue.getIssueTypeObject().getId()).getFieldLayoutItem(fieldId); if (fieldLayoutItem == null) { return new Html(value); } return new Html(rendererManager.getRenderedContent(fieldLayoutItem.getRendererType(), value, issue.getIssueRenderContext())); }
/** * @return null if the input is null */ public static CommentJsonBean renderedShortBean(Comment comment, JiraBaseUrls urls, ProjectRoleManager projectRoleManager, DateTimeFormatterFactory dateTimeFormatterFactory, RendererManager rendererManager, String rendererType, IssueRenderContext renderContext, ApplicationUser loggedInUser, EmailFormatter emailFormatter) { if (comment == null) { return null; } final CommentJsonBean bean = new CommentJsonBean(); addNonRenderableStuff(bean, comment, urls, projectRoleManager, loggedInUser, emailFormatter); if (StringUtils.isNotBlank(rendererType)) { bean.body = rendererManager.getRenderedContent(rendererType, comment.getBody(), renderContext); } else { bean.body = comment.getBody(); } bean.created = comment.getCreated() == null ? "" : dateTimeFormatterFactory.formatter().forLoggedInUser().format(comment.getCreated()); bean.updated = comment.getUpdated() == null ? "" : dateTimeFormatterFactory.formatter().forLoggedInUser().format(comment.getUpdated()); return bean; }
public static WorklogJsonBean getRenderedWorklog(final Worklog log, final JiraBaseUrls baseUrls, String rendererType, IssueRenderContext renderContext, final ApplicationUser loggedInUser, final EmailFormatter emailFormatter) { final WorklogJsonBean bean = new WorklogJsonBean(); addNonRenderableData(bean, log, baseUrls, ComponentAccessor.getUserManager(), loggedInUser, emailFormatter); if (StringUtils.isNotBlank(rendererType)) { RendererManager rendererManager = ComponentAccessor.getComponent(RendererManager.class); bean.comment = rendererManager.getRenderedContent(rendererType, log.getComment(), renderContext); } else { bean.comment = log.getComment(); } JiraDurationUtils jiraDurationUtils = ComponentAccessor.getComponent(JiraDurationUtils.class); bean.timeSpent = jiraDurationUtils.getFormattedDuration(log.getTimeSpent(), ComponentAccessor.getJiraAuthenticationContext().getLocale()); DateTimeFormatterFactory dateTimeFormatterFactory = ComponentAccessor.getComponent(DateTimeFormatterFactory.class); bean.created = log.getCreated() == null ? "" : dateTimeFormatterFactory.formatter().forLoggedInUser().format(log.getCreated()); bean.updated = log.getUpdated() == null ? "" : dateTimeFormatterFactory.formatter().forLoggedInUser().format(log.getUpdated()); bean.started = log.getStartDate() == null ? "" : dateTimeFormatterFactory.formatter().forLoggedInUser().format(log.getStartDate()); return bean; }