/** * Provides XML snippet of the record. * * @return XML snippet of the record */ public String toXmlSnippet() { StringBuilder sb = new StringBuilder(); sb.append("<record>\n"); sb.append("<sourceUri>" + Val.escapeXml(sourceUri) + "</sourceUri>\n"); if (!validated) { sb.append("<validate>\n"); sb.append("<status>failed</status>\n"); for (String error : errors) { sb.append("<error>" + Val.escapeXml(error) + "</error>\n"); } sb.append("</validate>\n"); } else { sb.append("<validate><status>ok</status></validate>\n"); if (!published) { sb.append("<publish>\n"); sb.append("<status>failed</status>\n"); for (String error : errors) { sb.append("<error>" + Val.escapeXml(error) + "</error>\n"); } sb.append("</publish>\n"); } else { sb.append("<publish><status>ok</status></publish>\n"); } } sb.append("</record>\n"); return sb.toString(); }
/** * Writes abstract section. * * @param record record */ private void writeAbstract(SearchResultRecord record) { String sAbstract = Val.chkStr(record.getAbstract()); if (sAbstract.length() > 0) { sAbstract = !getClipText() ? sAbstract : sAbstract.length() > CLIP_TEXT_LENGTH ? sAbstract.substring(0, CLIP_TEXT_LENGTH) + "..." : sAbstract; String divStyle = "overflow: auto;"; _writer.println("<div class=\"" + ABSTRACT_STYLE_CLASS + "\" style=\"" + divStyle + "\" >"); String url = Val.chkStr(record.getResourceLinks().getThumbnail().getUrl()); if (url.length() > 0) { url = Val.escapeXml(url); String imgStyle = "float:right; margin-left:0.5em; width:64px; height:64px; border:1px solid #000000;"; // imgStyle = "border:1px solid #000000;"; _writer.println( "<img class=\"" + THUMBNAIL_STYLE_CLASS + "\" src=\"" + url + "\" style=\"" + imgStyle + "\"/>"); } _writer.println(Val.escapeXmlForBrowser(sAbstract)); _writer.println("</div>"); } }