topicFolder = services.getNodeService().getChildAssocs(forumFolder, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, COMMENTS_TOPIC_NAME));
+ result = topicFolder.isEmpty() ? null : topicFolder.get(0).getChildRef();
+ }
+ return result;
+ }
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/blogs/RequestUtilsLibJs.java b/source/java/org/alfresco/repo/web/scripts/blogs/RequestUtilsLibJs.java
new file mode 100644
index 0000000000..7287f6e342
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/blogs/RequestUtilsLibJs.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.blogs;
+
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.repo.jscript.ScriptNode;
+import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator;
+import org.alfresco.repo.nodelocator.NodeLocatorService;
+import org.alfresco.repo.nodelocator.SitesHomeNodeLocator;
+import org.alfresco.repo.nodelocator.UserHomeNodeLocator;
+import org.alfresco.repo.search.QueryParameterDefImpl;
+import org.alfresco.repo.security.permissions.AccessDeniedException;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.search.QueryParameterDefinition;
+import org.alfresco.service.cmr.site.SiteInfo;
+import org.alfresco.service.namespace.NamespaceService;
+import org.alfresco.service.namespace.QName;
+import org.springframework.extensions.webscripts.WebScriptException;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * This class is a port of a previous JavaScript library.
+ *
+ * @author Neil Mc Erlean (based on previous JavaScript)
+ * @since 4.0
+ * @deprecated Not to be used/extended as this is likely to be refactored.
+ */
+public class RequestUtilsLibJs
+{
+ //FIXME It will be refactored when the other services are ported from JavaScript to Java.
+
+ /**
+ * Gets the NodeRef requested based on the following templates:
+ *
+ *
+ * /api/blog/site/{site}/{container}/{path}/posts
+ * /api/blog/site/{site}/{container}/posts
+ * /api/blog/node/{store_type}/{store_id}/{id}/posts
+ *
+ */
+ public static NodeRef getRequestNode(WebScriptRequest req, ServiceRegistry services)
+ {
+ NodeRef result = null;
+
+ Map templateVars = req.getServiceMatch().getTemplateVars();
+
+ // If the template args contains a "store_type" then we we have a standard NodeRef URI template pattern
+ // check whether we got a node reference or a site related uri
+ final String storeType = templateVars.get("store_type");
+ final String site = templateVars.get("site");
+ if (storeType != null)
+ {
+ result = findFromReference(templateVars, services);
+ }
+ else if (site != null)
+ {
+ result = findNodeInSite(templateVars, services);
+ }
+ else
+ {
+ throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unknown request parameters (webscript incorrectly configured?)");
+ }
+
+ if (!services.getNodeService().exists(result))
+ {
+ throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + result.toString());
+ }
+
+ return result;
+ }
+
+ private static NodeRef findFromReference(final Map templateVars, ServiceRegistry services)
+ {
+ NodeRef result = null;
+
+ String nodeRefString = templateVars.get("store_type") + "://" + templateVars.get("store_id") + "/" + templateVars.get("id");
+
+ // These webscripts support some non-standard NodeRef URI constructions.
+
+ NodeLocatorService nodeLocatorService = services.getNodeLocatorService();
+ if (nodeRefString.equals("alfresco://company/home"))
+ {
+ result = nodeLocatorService.getNode(CompanyHomeNodeLocator.NAME, null, null);
+ }
+ else if (nodeRefString.equals("alfresco://user/home"))
+ {
+ result = nodeLocatorService.getNode(UserHomeNodeLocator.NAME, null, null);
+ }
+ else if (nodeRefString.equals("alfresco://sites/home"))
+ {
+ result = nodeLocatorService.getNode(SitesHomeNodeLocator.NAME, null, null);
+ }
+ else if (NodeRef.isNodeRef(nodeRefString))
+ {
+ result = new NodeRef(nodeRefString);
+ }
+ else
+ {
+// result = new Nodesearch.findNode(nodeRef);
+ }
+
+ if (result == null)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Node " + nodeRefString + "does not exist");
+ }
+ return result;
+ }
+
+ /**
+ * Returns the node as specified by the given arguments.
+ *
+ * @param siteId the site for which a node is requested
+ * @param containerId the component to look in for the node.
+ * @param path a path to the node. Returns the root node in case path is null or ''
+ * return null in case no node can be found for the given path
+ * @return the node or a json error in case the node could not be fetched. Check with .
+ */
+ private static NodeRef findNodeInSite(final Map templateVars, ServiceRegistry services)
+ {
+ final String siteId = templateVars.get("site");
+ final String containerId = templateVars.get("container");
+ String path = templateVars.get("path");
+ if (path == null) path = "";
+
+ SiteInfo site = services.getSiteService().getSite(siteId);
+ if (site == null)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Site not found: '" + siteId + "'");
+ }
+
+ NodeRef node = services.getSiteService().getContainer(siteId, containerId);
+ if (node == null)
+ {
+ node = services.getSiteService().createContainer(siteId, containerId, null, null);
+ if (node == null)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to fetch container '" + containerId + "' of site '" + siteId + "'. (No write permission?)");
+ }
+ }
+
+ // try to fetch the the path is there is any
+ if (path != null && !path.isEmpty())
+ {
+ node = childByNamePath(path, node, services);
+ if (node == null)
+ {
+ throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "No node found for the given path: \"" + path + "\" in container " + containerId + " of site " + siteId);
+ }
+ }
+
+ return node;
+ }
+
+
+ /**
+ * Gets a descendant node by navigating a cm:name-based path e.g. /QA/Testing/Docs
+ *
+ * @see ScriptNode#childByNamePath(String)
+ */
+ private static NodeRef childByNamePath(String path, NodeRef rootNode, ServiceRegistry services)
+ {
+ // This is based partially on ScriptNode.childByNamePath, but supports less path variations.
+ NodeRef result = null;
+ QName nodeType = services.getNodeService().getType(rootNode);
+
+ if (services.getDictionaryService().isSubClass(nodeType, ContentModel.TYPE_FOLDER))
+ {
+ /**
+ * The current node is a folder.
+ * optimized code path for cm:folder and sub-types supporting getChildrenByName() method
+ */
+ StringTokenizer t = new StringTokenizer(path, "/");
+ if (t.hasMoreTokens())
+ {
+ result = rootNode;
+ while (t.hasMoreTokens() && result != null)
+ {
+ String name = t.nextToken();
+ try
+ {
+ result = services.getNodeService().getChildByName(result, ContentModel.ASSOC_CONTAINS, name);
+ }
+ catch (AccessDeniedException ade)
+ {
+ result = null;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogGet.java b/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogGet.java
new file mode 100644
index 0000000000..eb69cf8b12
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogGet.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.blogs.blog;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript;
+import org.alfresco.repo.web.scripts.blogs.RequestUtilsLibJs;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * This class is the controller for the blog.get web script.
+ *
+ * @author Neil Mc Erlean (based on existing JavaScript webscript controllers)
+ * @since 4.0
+ */
+public class BlogGet extends AbstractBlogWebScript
+{
+ @Override
+ protected Map executeImpl(WebScriptRequest req, Status status, Cache cache)
+ {
+ Map model = new HashMap();
+
+ // get requested node
+ NodeRef node = RequestUtilsLibJs.getRequestNode(req, services);
+ model.put(ITEM, node);
+
+ return model;
+ }
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java b/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java
new file mode 100644
index 0000000000..992cf1457a
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.blogs.blog;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.error.AlfrescoRuntimeException;
+import org.alfresco.model.BlogIntegrationModel;
+import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript;
+import org.alfresco.repo.web.scripts.blogs.BlogLibJs;
+import org.alfresco.repo.web.scripts.blogs.RequestUtilsLibJs;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * This class is the controller for the blog.get web script.
+ *
+ * @author Neil Mc Erlean (based on existing JavaScript webscript controllers)
+ * @since 4.0
+ */
+public class BlogPut extends AbstractBlogWebScript
+{
+ @SuppressWarnings("deprecation")
+ @Override
+ protected Map executeImpl(WebScriptRequest req, Status status, Cache cache)
+ {
+ Map model = new HashMap();
+
+ // get requested node
+ NodeRef node = RequestUtilsLibJs.getRequestNode(req, services);
+
+ // parse the JSON
+ JSONObject json = null;
+ try
+ {
+ json = new JSONObject(new JSONTokener(req.getContent().getContent()));
+ } catch (JSONException jsonX)
+ {
+ throw new AlfrescoRuntimeException("Could not parse JSON", jsonX);
+ } catch (IOException iox)
+ {
+ throw new AlfrescoRuntimeException("Could not parse JSON", iox);
+ }
+
+ updateBlog(node, json);
+
+ model.put("item", node);
+
+ return model;
+ }
+
+ /**
+ * Creates a post inside the passed forum node.
+ */
+ @SuppressWarnings("deprecation")
+ private void updateBlog(NodeRef node, JSONObject json)
+ {
+ Map arr = BlogLibJs.getBlogPropertiesArray(json);
+
+ if (nodeService.hasAspect(node, BlogIntegrationModel.ASPECT_BLOG_DETAILS))
+ {
+ nodeService.setProperties(node, arr);
+ }
+ else
+ {
+ nodeService.addAspect(node, BlogIntegrationModel.ASPECT_BLOG_DETAILS, arr);
+ }
+ }
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostDelete.java b/source/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostDelete.java
new file mode 100644
index 0000000000..798488d71b
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostDelete.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.blogs.post;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript;
+import org.alfresco.repo.web.scripts.blogs.RequestUtilsLibJs;
+import org.alfresco.service.cmr.activities.ActivityPostService;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.json.JSONException;
+import org.json.JSONStringer;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * This class is the controller for the blog-posts.get web script.
+ *
+ * @author Neil Mc Erlean (based on existing JavaScript webscript controllers)
+ * @since 4.0
+ */
+public class BlogPostDelete extends AbstractBlogWebScript
+{
+ private ActivityPostService activityPostService;
+
+ public void setActivityPostService(ActivityPostService activityPostService)
+ {
+ this.activityPostService = activityPostService;
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected Map executeImpl(WebScriptRequest req, Status status, Cache cache)
+ {
+ Map model = new HashMap();
+
+ // get requested node
+ NodeRef node = RequestUtilsLibJs.getRequestNode(req, services);
+
+ // Map item = BlogPostLibJs.getBlogPostData(node, services);
+
+ final String title = (String) nodeService.getProperty(node, ContentModel.PROP_TITLE);
+ final String site = req.getServiceMatch().getTemplateVars().get("site");
+ final String page = req.getParameter("page");
+ final boolean isDraftBlogPost = blogService.isDraftBlogPost(node);
+
+ nodeService.deleteNode(node);
+
+ model.put("message", "Node " + node + " deleted");
+
+ if (site != null && !isDraftBlogPost)
+ {
+ sendActivityReport(title, site, page);
+ }
+
+ return model;
+ }
+
+ private void sendActivityReport(final String title, final String site,
+ final String page)
+ {
+ String data = null;
+ try
+ {
+ data = new JSONStringer()
+ .object()
+ .key(TITLE).value(title)
+ .key(PAGE).value(page)
+ .endObject().toString();
+ } catch (JSONException e)
+ {
+ // Intentionally empty
+ }
+ if (data != null)
+ {
+ activityPostService.postActivity("org.alfresco.blog.post-deleted", site, "blog", data);
+ }
+ }
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostGet.java b/source/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostGet.java
new file mode 100644
index 0000000000..d038b241e8
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostGet.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.blogs.post;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript;
+import org.alfresco.repo.web.scripts.blogs.BlogPostLibJs;
+import org.alfresco.repo.web.scripts.blogs.RequestUtilsLibJs;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * This class is the controller for the blog-posts.get web script.
+ *
+ * @author Neil Mc Erlean (based on existing JavaScript webscript controllers)
+ * @since 4.0
+ */
+public class BlogPostGet extends AbstractBlogWebScript
+{
+ @SuppressWarnings("deprecation")
+ @Override
+ protected Map executeImpl(WebScriptRequest req, Status status, Cache cache)
+ {
+ Map model = new HashMap();
+
+ // get requested node
+ NodeRef node = RequestUtilsLibJs.getRequestNode(req, services);
+ Map item = BlogPostLibJs.getBlogPostData(node, services);
+ model.put("item", item);
+
+ model.put("externalBlogConfig", BlogPostLibJs.hasExternalBlogConfiguration(node, services));
+
+ int contentLength = -1;
+ String arg = req.getParameter("contentLength");
+ if (arg != null)
+ {
+ try
+ {
+ contentLength = Integer.parseInt(arg);
+ }
+ catch (NumberFormatException ignored)
+ {
+ // Intentionally empty
+ }
+ }
+
+ model.put("contentLength", contentLength);
+
+ return model;
+ }
+}
diff --git a/source/java/org/alfresco/repo/web/scripts/blogs/posts/AbstractGetBlogWebScript.java b/source/java/org/alfresco/repo/web/scripts/blogs/posts/AbstractGetBlogWebScript.java
new file mode 100644
index 0000000000..3f44f809dc
--- /dev/null
+++ b/source/java/org/alfresco/repo/web/scripts/blogs/posts/AbstractGetBlogWebScript.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.web.scripts.blogs.posts;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.alfresco.query.PagingRequest;
+import org.alfresco.query.PagingResults;
+import org.alfresco.repo.blog.BlogPostInfo;
+import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript;
+import org.alfresco.repo.web.scripts.blogs.BlogPostLibJs;
+import org.alfresco.repo.web.scripts.blogs.RequestUtilsLibJs;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.util.Pair;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * @author Neil Mc Erlean (based on existing JavaScript webscript controllers)
+ * @since 4.0
+ */
+public abstract class AbstractGetBlogWebScript extends AbstractBlogWebScript
+{
+ @Override
+ protected Map executeImpl(WebScriptRequest req, Status status, Cache cache)
+ {
+ Map model = new HashMap();
+
+ // get requested node
+ NodeRef node = RequestUtilsLibJs.getRequestNode(req, services);
+
+ // process additional parameters.
+ PagingRequest pagingReq = parsePagingParams(req);
+
+ // begin and end date.
+ // Legacy note: these dates are URL query parameters in int form.
+ Date fromDate = parseDateParam(req, "fromDate");
+ Date toDate = parseDateParam(req, "toDate");
+
+ String tag = req.getParameter("tag");
+ if (tag != null && tag.length() == 0) tag = null;
+
+ // One webscript (blog-posts-new.get) uses a 'numdays' parameter as a 'fromDate'.
+ // This is a hacky solution to this special case. FIXME
+ if (this.getClass().equals(BlogPostsNewGet.class))
+ {
+ // Default is for 'now' minus seven days.
+ final int oneDayInMilliseconds = 24 * 60 * 60 * 1000;
+ final long sevenDaysInMilliseconds = 7 * oneDayInMilliseconds;
+ fromDate = new Date(System.currentTimeMillis() - sevenDaysInMilliseconds);
+
+ // But if there is a numdays parameter then that changes the fromDate
+ String numDays = req.getServiceMatch().getTemplateVars().get("numdays");
+ if (numDays != null)
+ {
+ Integer numDaysInt = Integer.parseInt(numDays);
+ fromDate = new Date(System.currentTimeMillis() - (numDaysInt * oneDayInMilliseconds));
+ }
+ }
+
+ // fetch and assign the data
+ PagingResults blogPostList = getBlogPostList(node, fromDate, toDate,
+ tag, pagingReq);
+
+ createFtlModel(req, model, node, pagingReq, blogPostList);
+
+ return model;
+ }
+
+ protected void createFtlModel(WebScriptRequest req, Map model, NodeRef node, PagingRequest pagingReq,
+ PagingResults blogPostList)
+ {
+ Map blogPostsData = new HashMap();
+
+ final Pair totalResultCount = blogPostList.getTotalResultCount();
+ //FIXME What to do? null
+ blogPostsData.put("total", totalResultCount.getFirst());
+ blogPostsData.put("pageSize", pagingReq.getMaxItems());
+ blogPostsData.put("startIndex", pagingReq.getSkipCount());
+ blogPostsData.put("itemCount", blogPostList.getPage().size());
+
+ List