use of io.clownfish.clownfish.dbentities.CfKeywordlist in project Clownfish by rawdog71.
the class GetKeywordLibraries method doGet.
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
String token = request.getParameter("token");
if (authtokenlist.checkValidToken(token)) {
String apikey = request.getParameter("apikey");
if (apikeyutil.checkApiKey(apikey, "RestService")) {
CfKeywordlist keywordlist = null;
List<CfKeywordlist> keywordlistList = new ArrayList<>();
String keywordlistid = request.getParameter("id");
if (keywordlistid != null) {
keywordlist = cfkeywordlistService.findById(Long.parseLong(keywordlistid));
keywordlistList.add(keywordlist);
}
String keywordlistname = request.getParameter("name");
if (keywordlistname != null) {
keywordlist = cfkeywordlistService.findByName(keywordlistname);
keywordlistList.clear();
keywordlistList.add(keywordlist);
}
if ((null == keywordlistid) && (null == keywordlistname)) {
keywordlistList = cfkeywordlistService.findAll();
}
ArrayList<RestKeywordListOutput> keywordlistoutputList = new ArrayList<>();
for (CfKeywordlist keywordlistItem : keywordlistList) {
List<CfKeyword> keywordList = new ArrayList<>();
List<CfKeywordlistcontent> keywordlistcontentList = cfkeywordlistcontentService.findByKeywordlistref(keywordlistItem.getId());
for (CfKeywordlistcontent keywordlistcontent : keywordlistcontentList) {
keywordList.add(cfkeywordService.findById(keywordlistcontent.getCfKeywordlistcontentPK().getKeywordref()));
}
RestKeywordListOutput keywordlistoutput = new RestKeywordListOutput();
keywordlistoutput.setKeywordlist(keywordlistItem);
keywordlistoutput.setKeywords(keywordList);
keywordlistoutputList.add(keywordlistoutput);
}
Gson gson = new Gson();
String json = gson.toJson(keywordlistoutputList);
response.setContentType("application/json;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
out.print(json);
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
}
} else {
PrintWriter out = response.getWriter();
out.print("Wrong API KEY");
}
} else {
PrintWriter out = response.getWriter();
out.print("Invalid Token");
}
} catch (javax.persistence.NoResultException | java.lang.IllegalArgumentException ex) {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
out.print("No keyword lists");
} catch (IOException ex1) {
LOGGER.error(ex1.getMessage());
}
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
}
}
use of io.clownfish.clownfish.dbentities.CfKeywordlist in project Clownfish by rawdog71.
the class SiteUtil method getSiteKeywordlibrary.
public Map getSiteKeywordlibrary(CfSite cfsite, Map sitecontentmap) {
List<CfSitekeywordlist> sitekeywordlibrary = new ArrayList<>();
sitekeywordlibrary.addAll(cfsitekeywordlistService.findBySiteref(cfsite.getId()));
HashMap<String, ArrayList> keywordlibraryMap = new HashMap<>();
for (CfSitekeywordlist sitekeywordlist : sitekeywordlibrary) {
CfKeywordlist cfkeywordlist = cfkeywordlistService.findById(sitekeywordlist.getCfSitekeywordlistPK().getKeywordlistref());
List<CfKeywordlistcontent> keywordlist = new ArrayList<>();
keywordlist.addAll(cfkeywordlistcontentService.findByKeywordlistref(cfkeywordlist.getId()));
ArrayList<CfKeyword> dummykeywordlist = new ArrayList<>();
for (CfKeywordlistcontent keywordcontent : keywordlist) {
CfKeyword keyword = cfkeywordService.findById(keywordcontent.getCfKeywordlistcontentPK().getKeywordref());
dummykeywordlist.add(keyword);
}
keywordlibraryMap.put(cfkeywordlist.getName(), dummykeywordlist);
}
sitecontentmap.put("KeywordLibrary", keywordlibraryMap);
return sitecontentmap;
}
use of io.clownfish.clownfish.dbentities.CfKeywordlist in project Clownfish by rawdog71.
the class SiteUtil method getSiteKeywordlibrary.
public Map getSiteKeywordlibrary(List<CfKeywordlist> keywordlibrary_list, Map sitecontentmap) {
HashMap<String, ArrayList> keywordlibraryMap = new HashMap<>();
for (CfKeywordlist cfkeywordlist : keywordlibrary_list) {
List<CfKeywordlistcontent> keywordlist = new ArrayList<>();
keywordlist.addAll(cfkeywordlistcontentService.findByKeywordlistref(cfkeywordlist.getId()));
ArrayList<CfKeyword> dummykeywordlist = new ArrayList<>();
for (CfKeywordlistcontent keywordcontent : keywordlist) {
CfKeyword keyword = cfkeywordService.findById(keywordcontent.getCfKeywordlistcontentPK().getKeywordref());
dummykeywordlist.add(keyword);
}
keywordlibraryMap.put(cfkeywordlist.getName(), dummykeywordlist);
}
sitecontentmap.put("KeywordLibrary", keywordlibraryMap);
return sitecontentmap;
}
use of io.clownfish.clownfish.dbentities.CfKeywordlist in project Clownfish by rawdog71.
the class SiteTreeBean method onSelect.
public void onSelect(NodeSelectEvent event) {
selectedNode = event.getTreeNode();
selectedSite = (CfSite) selectedNode.getData();
classcontentlist = cfclasscontentService.findByMaintenance(true);
if (null != selectedSite.getTemplateref()) {
CfTemplate template = cftemplateService.findById(selectedSite.getTemplateref().longValue());
int idx = templatelist.getTemplateListe().indexOf(template);
selectedTemplate = templatelist.getTemplateListe().get(idx);
iframeurl = selectedSite.getName() + "?preview=true";
selectedDiv = null;
showContent = false;
showDatalist = false;
showAsset = false;
showAssetLibrary = false;
showKeywordLibrary = false;
if (template.isLayout()) {
contenteditable = true;
FacesMessage message = new FacesMessage("LAYOUT TEMPLATE");
FacesContext.getCurrentInstance().addMessage(null, message);
// List<CfLayoutcontent> layoutcontent = cflayoutcontentService.findBySiteref(selectedSite.getId());
layout = new CfLayout(template.getName());
Document doc = Jsoup.parse(template.getContent());
Elements divs = doc.getElementsByAttribute("template");
for (Element div : divs) {
String contents = div.attr("contents");
String datalists = div.attr("datalists");
String assets = div.attr("assets");
String assetlists = div.attr("assetlists");
String keywordlists = div.attr("keywordlists");
CfDiv cfdiv = new CfDiv();
cfdiv.setId(div.attr("id"));
cfdiv.setName(div.attr("template"));
if (!contents.isEmpty()) {
cfdiv.getContentArray().addAll(ClownfishUtil.toList(contents.split(",")));
}
if (!datalists.isEmpty()) {
cfdiv.getContentlistArray().addAll(ClownfishUtil.toList(datalists.split(",")));
}
if (!assets.isEmpty()) {
cfdiv.getAssetArray().addAll(ClownfishUtil.toList(assets.split(",")));
}
if (!assetlists.isEmpty()) {
cfdiv.getAssetlistArray().addAll(ClownfishUtil.toList(assetlists.split(",")));
}
if (!keywordlists.isEmpty()) {
cfdiv.getKeywordlistArray().addAll(ClownfishUtil.toList(keywordlists.split(",")));
}
layout.getDivArray().put(div.attr("id"), cfdiv);
}
} else {
contenteditable = false;
selected_contentclass = null;
selected_datalisttclass = null;
selected_asset = null;
selected_assetlist = null;
selected_keywordlist = null;
}
} else {
selectedTemplate = null;
}
if (null != selectedSite.getStylesheetref()) {
CfStylesheet styleshet = cfstylesheetService.findById(selectedSite.getStylesheetref().longValue());
int idx = stylesheetlist.getStylesheetListe().indexOf(styleshet);
selectedStylesheet = stylesheetlist.getStylesheetListe().get(idx);
} else {
selectedStylesheet = null;
}
if (null != selectedSite.getJavascriptref()) {
CfJavascript javascript = cfjavascriptService.findById(selectedSite.getJavascriptref().longValue());
int idx = javascriptlist.getJavascriptListe().indexOf(javascript);
selectedJavascript = javascriptlist.getJavascriptListe().get(idx);
} else {
selectedJavascript = null;
}
selectedDatasources.clear();
List<CfSitedatasource> selectedSiteDatasources = cfsitedatasourceService.findBySiteref(selectedSite.getId());
for (CfSitedatasource sitedatasource : selectedSiteDatasources) {
CfDatasource ds = cfdatasourceService.findById(sitedatasource.getCfSitedatasourcePK().getDatasourceref());
selectedDatasources.add(ds);
}
selectedContentlist.clear();
List<CfSitelist> selectedSitecontentlist = cfsitelistService.findBySiteref(selectedSite.getId());
for (CfSitelist sitelist : selectedSitecontentlist) {
CfList cl = cflistService.findById(sitelist.getCfSitelistPK().getListref());
selectedContentlist.add(cl);
}
selectedClasscontentlist.clear();
List<CfSitecontent> selectedClasscontentliste = cfsitecontentService.findBySiteref(selectedSite.getId());
for (CfSitecontent sitecontent : selectedClasscontentliste) {
CfClasscontent cc = cfclasscontentService.findById(sitecontent.getCfSitecontentPK().getClasscontentref());
selectedClasscontentlist.add(cc);
}
selectedAssetlist.clear();
List<CfSiteassetlist> selectedAssetliste = cfsiteassetlistService.findBySiteref(selectedSite.getId());
for (CfSiteassetlist siteassetlist : selectedAssetliste) {
CfAssetlist csa = cfassetlistService.findById(siteassetlist.getCfSiteassetlistPK().getAssetlistref());
selectedAssetlist.add(csa);
}
selectedKeywordlist.clear();
List<CfSitekeywordlist> selectedKeywordliste = cfsitekeywordlistService.findBySiteref(selectedSite.getId());
for (CfSitekeywordlist sitekeywordlist : selectedKeywordliste) {
CfKeywordlist kwl = cfkeywordlistService.findById(sitekeywordlist.getCfSitekeywordlistPK().getKeywordlistref());
selectedKeywordlist.add(kwl);
}
siteName = selectedSite.getName();
siteTitle = selectedSite.getTitle();
siteDescription = selectedSite.getDescription();
sitejob = selectedSite.isJob();
sitesearchrelevant = selectedSite.isSearchrelevant();
sitemap = selectedSite.isSitemap();
sitestatic = selectedSite.isStaticsite();
aliaspath = selectedSite.getAliaspath();
sitehtmlcompression = selectedSite.getHtmlcompression();
characterEncoding = selectedSite.getCharacterencoding();
contentType = selectedSite.getContenttype();
locale = selectedSite.getLocale();
saprfclist = cfsitesaprfcService.findBySiteref(selectedSite.getId());
newButtonDisabled = true;
FacesMessage message = new FacesMessage("Selected " + selectedSite.getName());
FacesContext.getCurrentInstance().addMessage(null, message);
}
use of io.clownfish.clownfish.dbentities.CfKeywordlist in project Clownfish by rawdog71.
the class SiteTreeBean method onSelectLayoutKeywordlibrary.
/**
* Selects a Keywordlibrary
* @param event
*/
public void onSelectLayoutKeywordlibrary(SelectEvent event) {
CfKeywordlist selected_keywordlist = (CfKeywordlist) event.getObject();
previewKeywordlistOutput.clear();
for (CfKeywordlistcontent keywordlistcontent : cfkeywordlistcontentService.findByKeywordlistref(selected_keywordlist.getId())) {
previewKeywordlistOutput.add(cfkeywordService.findById(keywordlistcontent.getCfKeywordlistcontentPK().getKeywordref()));
}
}
Aggregations