19 package org.turro.newsletter;
21 import com.sun.syndication.feed.synd.SyndContent;
22 import com.sun.syndication.feed.synd.SyndContentImpl;
23 import com.sun.syndication.feed.synd.SyndEntry;
24 import com.sun.syndication.feed.synd.SyndEntryImpl;
25 import java.io.IOException;
26 import java.io.PrintWriter;
27 import java.util.ArrayList;
28 import java.util.List;
29 import javax.servlet.ServletException;
30 import org.turro.string.ObjectString;
31 import org.turro.string.Strings;
32 import org.turro.elephant.context.ElephantContext;
33 import org.turro.elephant.context.IElement;
34 import org.turro.elephant.feed.IRSSable;
35 import org.turro.elephant.impl.abstracts.AbstractElement;
36 import org.turro.elephant.layout.IManageable;
37 import org.turro.elephant.layout.IRenderable;
38 import org.turro.elephant.search.FoundList;
39 import org.turro.elephant.search.ISearchable;
40 import org.turro.elephant.search.SearchFormatter;
41 import org.turro.elephant.security.IDefendable;
42 import org.turro.jpa.entity.EntityWebUrls;
43 import org.turro.jpa.search.DaoHtmlSearch;
44 import org.turro.publication.db.PublicationPU;
45 import org.turro.publication.entity.Publication;
46 import org.turro.publication.util.PublicationCategories;
47 import org.turro.publication.www.CategoryFilter;
48 import org.turro.publication.www.PublicationIterator;
56 protected String
sclass, contactId, fullTemplate, summaryTemplate;
57 protected long groupId, categoryId, publicationId;
66 public void loadData() throws ServletException, IOException {
68 fullTemplate =
getAttributes().getAttributeValue(
"attrib:fullTemplate",
"");
69 summaryTemplate =
getAttributes().getAttributeValue(
"attrib:summaryTemplate",
"");
70 contactId =
getAttributes().getAttributeValue(
"attrib:contactId",
null);
72 categoryId =
getAttributes().getAttributeIntegerValue(
"attrib:categoryId", 0);
73 publicationId =
getAttributes().getAttributeIntegerValue(
"attrib:publicationId", 0);
76 if(publicationId > 0) {
103 if(publicationId > 0) {
108 if(categoryId == 0) {
126 return "<div class='" +
sclass +
"publication-web'>";
148 0,
groupId, categoryId, contactId,
true, extraSql);
153 sf.
processLine(pub.getPublicationCategory().getName());
178 contactId =
getAttributes().getAttributeValue(
"attrib:contactId",
null);
180 categoryId =
getAttributes().getAttributeIntegerValue(
"attrib:categoryId", 0);
182 SyndContent description;
183 List<SyndEntry> entries =
new ArrayList<>();
184 int rsscount = this.
getAttributes().getAttributeIntegerValue(
"attrib:rss_count", 10);
186 rsscount,
groupId, categoryId, contactId,
true);
189 entry =
new SyndEntryImpl();
190 entry.setTitle(pub.getTitle());
192 entry.setPublishedDate(pub.getDate());
193 entry.setAuthor(pub.getAuthor());
194 description =
new SyndContentImpl();
195 description.setType(
"text/html");
196 String summary = pub.getSummary();
197 if(!Strings.isBlank(summary)) {
198 summary = summary.replaceAll(
"href=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'",
"href=\\'" + serverBase +
"$1$2\\'")
199 .replaceAll(
"src=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'",
"src=\\'" + serverBase +
"$1$2\\'")
200 .replaceAll(
"href=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"",
"href=\\\"" + serverBase +
"$1$2\\\"")
201 .replaceAll(
"src=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"",
"src=\\\"" + serverBase +
"$1$2\\\"");
202 description.setValue(summary);
204 entry.setDescription(description);
215 return "?pubid=" + pub.
getId() +
"&item=" + pub.
getId();
static String getRootResourcePath()
static String getServerBase(String scheme)
static String getContextVariable(IConstructor constructor)
AttributeSupport getAttributes()
void addItem(String id, String link, String image, String title, String value, double similarity, String query)
static String getUrlFromEntity(Object entity)
void setFullTemplate(String fullTemplate)
void setSearchEngine(DaoHtmlSearch searchEngine)
Collection< String > getMetas()
void setSummaryTemplate(String summaryTemplate)
static DaoHtmlSearch getInstance(IConstructor constructor, String context)
List< SyndEntry > getSyndEntries()
FoundList search(String value, boolean ignoreCase)
static List< Publication > getPublicationsBy(int max, long group, long category, String idContact, boolean accepted)
void setContactId(String contactId)
void setCategoryId(long categoryId)
void setCategoryFilter(CategoryFilter categoryFilter)
void setGroupId(long groupId)
String getParameter(String param)
void setTitle(String title)
IConstructor getConstructor()
void setMetas(Collection< String > metas)