diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.desc.xml
new file mode 100644
index 0000000000..41d59b6859
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.desc.xml
@@ -0,0 +1,10 @@
+
+ Blog posts
+ Get all posts for a blog
+ /blog/site/{site}/{container}/{path}/posts/mydrafts
+ /blog/site/{site}/{container}/posts/mydrafts
+ /blog/node/{store_type}/{store_id}/{id}/posts/mydrafts
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.js
new file mode 100644
index 0000000000..7cac7371ec
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.js
@@ -0,0 +1,43 @@
+
+
+
+
+
+/**
+ * Fetches all posts of the given blog
+ */
+function getBlogPostList(node, index, count)
+{
+ // query information
+ var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" " +
+ "+PATH:\"" + node.qnamePath + "/*\" ";
+
+ // add the drafts part
+ luceneQuery += "-ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
+ "+@cm\\:creator:\"" + person.properties.userName + "\"";
+
+ var sortAttribute = "@{http://www.alfresco.org/model/content/1.0}created";
+
+ // get the data
+ return getPagedResultsDataByLuceneQuery(node, luceneQuery, sortAttribute, false, index, count, getBlogPostData);
+}
+
+function main()
+{
+ // get requested node
+ var node = getRequestNode();
+ if (status.getCode() != status.STATUS_OK)
+ {
+ return;
+ }
+
+ // process additional parameters
+ var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
+ var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
+
+ // fetch and assign the data
+ model.data = getBlogPostList(node, index, count);
+ model.contentFormat = (args["contentFormat"] != undefined) ? args["contentFormat"] : "full";
+}
+
+main();
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.json.ftl
new file mode 100644
index 0000000000..84d5165a72
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.json.ftl
@@ -0,0 +1,5 @@
+<#import "../blogpost.lib.ftl" as blogpostLib/>
+<#import "../../generic-paged-results.lib.ftl" as gen/>
+<@gen.pagedResults data=data ; item>
+ <@blogpostLib.blogpostJSON item=item />
+@gen.pagedResults>
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.desc.xml
new file mode 100644
index 0000000000..491732604a
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.desc.xml
@@ -0,0 +1,10 @@
+
+ Blog posts
+ Get all posts for a blog
+ /blog/site/{site}/{container}/{path}/posts/mypublished
+ /blog/site/{site}/{container}/posts/mypublished
+ /blog/node/{store_type}/{store_id}/{id}/posts/mypublished
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.js
new file mode 100644
index 0000000000..a1b6c9529b
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.js
@@ -0,0 +1,44 @@
+
+
+
+
+
+/**
+ * Fetches all posts of the given blog
+ */
+function getBlogPostList(node, index, count)
+{
+ // query information
+ var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"" +
+ " +PATH:\"" + node.qnamePath + "/*\" ";
+
+ // add the drafts part
+ luceneQuery += "+ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
+ "+@cm\\:creator:\"" + person.properties.userName + "\"";
+
+
+ var sortAttribute = "@{http://www.alfresco.org/model/blogintegration/1.0}released";
+
+ // get the data
+ return getPagedResultsDataByLuceneQuery(node, luceneQuery, sortAttribute, false, index, count, getBlogPostData);
+}
+
+function main()
+{
+ // get requested node
+ var node = getRequestNode();
+ if (status.getCode() != status.STATUS_OK)
+ {
+ return;
+ }
+
+ // process additional parameters
+ var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
+ var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
+
+ // fetch and assign the data
+ model.data = getBlogPostList(node, index, count);
+ model.contentFormat = (args["contentFormat"] != undefined) ? args["contentFormat"] : "full";
+}
+
+main();
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.json.ftl
new file mode 100644
index 0000000000..84d5165a72
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.json.ftl
@@ -0,0 +1,5 @@
+<#import "../blogpost.lib.ftl" as blogpostLib/>
+<#import "../../generic-paged-results.lib.ftl" as gen/>
+<@gen.pagedResults data=data ; item>
+ <@blogpostLib.blogpostJSON item=item />
+@gen.pagedResults>
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.desc.xml
new file mode 100644
index 0000000000..7bb868ae7d
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.desc.xml
@@ -0,0 +1,10 @@
+
+ Blog posts
+ Get all posts for a blog
+ /blog/site/{site}/{container}/{path}/posts/new?numdays={numdays}
+ /blog/site/{site}/{container}/posts/new?numdays={numdays}
+ /blog/node/{store_type}/{store_id}/{id}/posts/new?numdays={numdays}
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.js
new file mode 100644
index 0000000000..ca646f2f3c
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.js
@@ -0,0 +1,46 @@
+
+
+
+
+
+const DEFAULT_NUM_DAYS = 7;
+
+/**
+ * Fetches all posts of the given blog
+ */
+function getBlogPostList(node, numdays, index, count)
+{
+ var fromDate = getTodayMinusXDays(numdays);
+
+ // query information
+ var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"" +
+ " +PATH:\"" + node.qnamePath + "/*\" " +
+ " +ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
+ getCreationDateRangeQuery(fromDate, null);
+
+ var sortAttribute = "@{http://www.alfresco.org/model/content/1.0}created";
+
+ // get the data
+ return getPagedResultsDataByLuceneQuery(node, luceneQuery, sortAttribute, false, index, count, getBlogPostData);
+}
+
+function main()
+{
+ // get requested node
+ var node = getRequestNode();
+ if (status.getCode() != status.STATUS_OK)
+ {
+ return;
+ }
+
+ // process additional parameters
+ var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
+ var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
+ var numdays = args["numdays"] != undefined ? parseInt(args["numdays"]) : DEFAULT_NUM_DAYS;
+
+ // fetch and assign the data
+ model.data = getBlogPostList(node, fromDate, toDate, index, count);
+ model.contentFormat = (args["contentFormat"] != undefined) ? args["contentFormat"] : "full";
+}
+
+main();
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.json.ftl
new file mode 100644
index 0000000000..84d5165a72
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.json.ftl
@@ -0,0 +1,5 @@
+<#import "../blogpost.lib.ftl" as blogpostLib/>
+<#import "../../generic-paged-results.lib.ftl" as gen/>
+<@gen.pagedResults data=data ; item>
+ <@blogpostLib.blogpostJSON item=item />
+@gen.pagedResults>
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.desc.xml
new file mode 100644
index 0000000000..97d1f24d19
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.desc.xml
@@ -0,0 +1,10 @@
+
+ Blog posts
+ Get all posts for a blog
+ /blog/site/{site}/{container}/{path}/posts/publishedext
+ /blog/site/{site}/{container}/posts/publishedext
+ /blog/node/{store_type}/{store_id}/{id}/posts/publishedext
+
+ user
+ required
+
\ No newline at end of file
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.js
new file mode 100644
index 0000000000..50d3a1dcd0
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.js
@@ -0,0 +1,42 @@
+
+
+
+
+
+/**
+ * Fetches all posts of the given blog
+ */
+function getBlogPostList(node, index, count)
+{
+ // query information
+ var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"" +
+ " +PATH:\"" + node.qnamePath + "/*\" ";
+
+ // add the drafts part
+ luceneQuery += "+ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}blogPost\" "
+
+ var sortAttribute = "@{http://www.alfresco.org/model/blogintegration/1.0}posted";
+
+ // get the data
+ return getPagedResultsDataByLuceneQuery(node, luceneQuery, sortAttribute, false, index, count, getBlogPostData);
+}
+
+function main()
+{
+ // get requested node
+ var node = getRequestNode();
+ if (status.getCode() != status.STATUS_OK)
+ {
+ return;
+ }
+
+ // process additional parameters
+ var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
+ var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
+
+ // fetch and assign the data
+ model.data = getBlogPostList(node, index, count);
+ model.contentFormat = (args["contentFormat"] != undefined) ? args["contentFormat"] : "full";
+}
+
+main();
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.json.ftl
new file mode 100644
index 0000000000..84d5165a72
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.json.ftl
@@ -0,0 +1,5 @@
+<#import "../blogpost.lib.ftl" as blogpostLib/>
+<#import "../../generic-paged-results.lib.ftl" as gen/>
+<@gen.pagedResults data=data ; item>
+ <@blogpostLib.blogpostJSON item=item />
+@gen.pagedResults>
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.js
index 2aa41fc218..ea96dc1a46 100644
--- a/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.js
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.js
@@ -11,6 +11,15 @@ function getBlogPostList(node, fromDate, toDate, index, count)
// query information
var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"" +
" +PATH:\"" + node.qnamePath + "/*\" ";
+
+ // include all published + my drafts
+ luceneQuery += "((" +
+ " -ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
+ "+@cm\\:creator:\"" + person.properties.userName + "\"" +
+ ") OR (" +
+ " +ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
+ "))";
+
// date query ?
if (fromDate != null || toDate != null)
{
@@ -36,9 +45,6 @@ function main()
var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
- // check what drafts we want to fetch
-
-
// begin and end date
var fromDate = null;
if (args["fromDate"] != undefined)
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-new.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-new.get.js
index b6345fc61b..d612d886fd 100644
--- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-new.get.js
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-new.get.js
@@ -5,18 +5,6 @@
const DEFAULT_NUM_DAYS = 30;
-/**
- * Returns the date object for the date "numdays" ago
- */
-function getTodayMinusXDays(numdays)
-{
- var date = new Date();
- var dateMillis = new Date().getTime();
- dateMillis -= 1000 * 60 * 60 * 24 * numdays;
- date.setTime(dateMillis);
- return date;
-}
-
/**
* Fetches all posts added to the forum in the last numdays days
*/
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js b/config/alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js
index abf1237302..bd3283b5cf 100644
--- a/config/alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js
@@ -5,6 +5,22 @@
const FUTURE_DATE = "3000\\-12\\-31T00:00:00";
const ZERO_DATE = "1970\\-01\\-01T00:00:00";
+/**
+ * Returns the date object for the date "numdays" ago
+ */
+function getTodayMinusXDays(numdays)
+{
+ var date = new Date();
+ var dateMillis = new Date().getTime();
+ dateMillis -= 1000 * 60 * 60 * 24 * numdays;
+ date.setTime(dateMillis);
+
+ // PENDING: should it be from the beginning of the date or exactly x days back?
+
+ return date;
+}
+
+
/**
* Returns the date string as required by Lucene,
* thus in the format "1970\\-01\\-01T00:00:00"