From f63354466a06c3d87d1d58b5a10d3ebb9b375e4b Mon Sep 17 00:00:00 2001 From: Alex Mukha Date: Thu, 28 Mar 2019 13:42:57 +0000 Subject: [PATCH] REPO-3236: Remove blogs (#177) --- l10n.properties | 2 +- pom.xml | 2 +- .../scripts/blogs/AbstractBlogWebScript.java | 311 ------ .../repo/web/scripts/blogs/BlogLibJs.java | 71 -- .../repo/web/scripts/blogs/BlogPostLibJs.java | 132 --- .../repo/web/scripts/blogs/CommentsLibJs.java | 99 -- .../repo/web/scripts/blogs/blog/BlogGet.java | 81 -- .../repo/web/scripts/blogs/blog/BlogPut.java | 104 -- .../scripts/blogs/post/BlogPostDelete.java | 82 -- .../web/scripts/blogs/post/BlogPostGet.java | 88 -- .../blogs/posts/AbstractGetBlogWebScript.java | 229 ---- .../web/scripts/blogs/posts/BlogPostsGet.java | 61 -- .../blogs/posts/BlogPostsMyDraftsGet.java | 59 -- .../blogs/posts/BlogPostsMyPublishedGet.java | 59 -- .../scripts/blogs/posts/BlogPostsNewGet.java | 57 - .../blogs/posts/BlogPostsPerMonthGet.java | 170 --- .../scripts/blogs/posts/BlogPostsPost.java | 304 ------ .../blogs/posts/BlogPostsPublishedExtGet.java | 57 - .../blogs/web-scripts-blog-context.xml | 77 -- .../alfresco/blog/post-created.atomentry.ftl | 14 - .../alfresco/blog/post-deleted.atomentry.ftl | 14 - .../alfresco/blog/post-updated.atomentry.ftl | 14 - .../alfresco/repository/blogs/blog.lib.ftl | 31 - .../org/alfresco/repository/blogs/blog.lib.js | 49 - .../repository/blogs/blog/blog.get.desc.xml | 11 - .../repository/blogs/blog/blog.get.json.ftl | 4 - .../repository/blogs/blog/blog.put.desc.xml | 11 - .../repository/blogs/blog/blog.put.json.ftl | 4 - .../repository/blogs/blogpost.lib.ftl | 116 -- .../alfresco/repository/blogs/blogpost.lib.js | 130 --- .../post/blog-post-publishing.post.desc.xml | 10 - .../post/blog-post-publishing.post.json.ftl | 2 - .../post/blog-post-publishing.post.json.js | 88 -- .../blogs/post/blog-post.delete.desc.xml | 10 - .../blogs/post/blog-post.delete.json.ftl | 3 - .../blogs/post/blog-post.delete.properties | 1 - .../blogs/post/blog-post.delete_de.properties | 1 - .../blogs/post/blog-post.delete_es.properties | 1 - .../blogs/post/blog-post.delete_fr.properties | 1 - .../blogs/post/blog-post.delete_it.properties | 1 - .../blogs/post/blog-post.delete_ja.properties | 1 - .../blogs/post/blog-post.delete_nb.properties | 1 - .../blogs/post/blog-post.delete_nl.properties | 1 - .../post/blog-post.delete_pt_BR.properties | 1 - .../blogs/post/blog-post.delete_ru.properties | 1 - .../post/blog-post.delete_zh_CN.properties | 1 - .../blogs/post/blog-post.get.desc.xml | 10 - .../blogs/post/blog-post.get.json.ftl | 2 - .../blogs/post/blog-post.put.desc.xml | 10 - .../blogs/post/blog-post.put.json.ftl | 2 - .../blogs/post/blog-post.put.json.js | 91 -- .../posts/blog-posts-mydrafts.get.desc.xml | 11 - .../posts/blog-posts-mydrafts.get.json.ftl | 2 - .../posts/blog-posts-mypublished.get.desc.xml | 11 - .../posts/blog-posts-mypublished.get.json.ftl | 2 - .../blogs/posts/blog-posts-new.get.desc.xml | 11 - .../blogs/posts/blog-posts-new.get.json.ftl | 2 - .../posts/blog-posts-per-month.get.desc.xml | 11 - .../posts/blog-posts-per-month.get.json.ftl | 17 - .../blog-posts-publishedext.get.desc.xml | 11 - .../blog-posts-publishedext.get.json.ftl | 2 - .../blogs/posts/blog-posts.get.desc.xml | 11 - .../blogs/posts/blog-posts.get.json.ftl | 2 - .../blogs/posts/blog-posts.post.desc.xml | 11 - .../blogs/posts/blog-posts.post.json.ftl | 2 - .../web-scripts-application-context.xml | 7 - .../org/alfresco/AppContext04TestSuite.java | 1 - .../ReadOnlyTransactionInGetRestApiTest.java | 11 - .../repo/web/scripts/WebScriptTestSuite.java | 2 - .../repo/web/scripts/blogs/AllBlogTests.java | 49 - .../web/scripts/blogs/BlogServiceTest.java | 998 ------------------ .../scripts/calendar/CalendarRestApiTest.java | 52 +- .../web/scripts/comment/CommentsApiTest.java | 2 +- 73 files changed, 29 insertions(+), 3881 deletions(-) delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/AbstractBlogWebScript.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/BlogLibJs.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/BlogPostLibJs.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/CommentsLibJs.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/blog/BlogGet.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostDelete.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostGet.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/posts/AbstractGetBlogWebScript.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsGet.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsMyDraftsGet.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsMyPublishedGet.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsNewGet.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPerMonthGet.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPost.java delete mode 100644 src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPublishedExtGet.java delete mode 100644 src/main/resources/alfresco/blogs/web-scripts-blog-context.xml delete mode 100644 src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-created.atomentry.ftl delete mode 100644 src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-deleted.atomentry.ftl delete mode 100644 src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-updated.atomentry.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog.lib.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog.lib.js delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.get.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.get.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.put.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.put.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.json.js delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_de.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_es.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_fr.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_it.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_ja.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_nb.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_nl.properties delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_pt_BR.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_ru.properties delete mode 100755 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_zh_CN.properties delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.get.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.get.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.json.js delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-per-month.get.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-per-month.get.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.json.ftl delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.desc.xml delete mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.json.ftl delete mode 100644 src/test/java/org/alfresco/repo/web/scripts/blogs/AllBlogTests.java delete mode 100644 src/test/java/org/alfresco/repo/web/scripts/blogs/BlogServiceTest.java diff --git a/l10n.properties b/l10n.properties index 0d33173c8c..0cf8bc0491 100644 --- a/l10n.properties +++ b/l10n.properties @@ -1,6 +1,6 @@ # Branch specific configuration file for localisation scripts -MESSAGE_SEARCH_PATH="src/main/resources/alfresco/messages/admin-console*.properties src/main/resources/alfresco/messages/custommodel-restapi-messages*.properties src/main/resources/alfresco/messages/rest-framework-messages*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/admin-communitysummary.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-repoconsole.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-tenantconsole.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-workflowconsole.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/support-tools/admin-nodebrowser.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/audit/entry*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links-delete.post*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links.post*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links.put*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/person/user-csv-upload.post*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.post*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put*.properties" +MESSAGE_SEARCH_PATH="src/main/resources/alfresco/messages/admin-console*.properties src/main/resources/alfresco/messages/custommodel-restapi-messages*.properties src/main/resources/alfresco/messages/rest-framework-messages*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/admin-communitysummary.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-repoconsole.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-tenantconsole.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/consoles/admin-workflowconsole.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/admin/support-tools/admin-nodebrowser.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/audit/entry*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links-delete.post*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links.post*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/links/links.put*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/person/user-csv-upload.post*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.get*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.post*.properties src/main/resources/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/event.put*.properties" EXCLUDED_FILES="src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/audit/control.properties" diff --git a/pom.xml b/pom.xml index a930c0ade6..5d9baa23f7 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ ${project.build.directory}/alf_data convert - 7.55 + 7.56 7.9 8.29 1.1 diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/AbstractBlogWebScript.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/AbstractBlogWebScript.java deleted file mode 100644 index fa0e0d157a..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/AbstractBlogWebScript.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs; - -import java.io.IOException; -import java.util.Map; - -import org.alfresco.repo.activities.post.lookup.PostLookup; -import org.alfresco.repo.blog.BlogServiceImpl; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.model.Repository; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.activities.ActivityService; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.blog.BlogService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONStringer; -import org.json.JSONWriter; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * @author Neil Mc Erlean - * @since 4.0 - */ -public abstract class AbstractBlogWebScript extends DeclarativeWebScript -{ - // Various common parameter strings in the blog webscripts. - protected static final String CONTAINER = "container"; - protected static final String CONTENT = "content"; - protected static final String DATA = "data"; - protected static final String DRAFT = "draft"; - protected static final String EXTERNAL_BLOG_CONFIG = "externalBlogConfig"; - protected static final String POST = "post"; - protected static final String ITEM = "item"; - protected static final String NODE = "node"; - protected static final String PAGE = "page"; - protected static final String SITE = "site"; - protected static final String TAGS = "tags"; - protected static final String TITLE = "title"; - - private static Log logger = LogFactory.getLog(AbstractBlogWebScript.class); - - // Injected services - protected Repository repository; - protected BlogService blogService; - protected NodeService nodeService; - protected SiteService siteService; - protected ActivityService activityService; - - //TODO Remove this after full refactor - protected ServiceRegistry services; - - public void setServiceRegistry(ServiceRegistry services) - { - this.services = services; - } - - public void setRepository(Repository repository) - { - this.repository = repository; - } - - public void setBlogService(BlogService blogService) - { - this.blogService = blogService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - public void setActivityService(ActivityService activityService) - { - this.activityService = activityService; - } - - /** - * Generates an activity entry for the discussion item - * - * @param event One of created, updated, deleted - * @param blog Either post or reply - * @param site site - * @param req request - * @param json json - * @param nodeRef NodeRef - */ - protected void addActivityEntry(String event, BlogPostInfo blog, - SiteInfo site, WebScriptRequest req, JSONObject json, NodeRef nodeRef) - { - // We can only add activities against a site - if (site == null) - { - logger.info("Unable to add activity entry for blog " + event + " as no site given"); - return; - } - - // What page is this for? - String page = req.getParameter("page"); - if (page == null && json != null) - { - if (json.containsKey("page")) - { - page = (String)json.get("page"); - } - } - if (page == null) - { - // Default - page = "blog-postview"; - } - if (page.indexOf('?') == -1) - { - page += "?postId=" + blog.getSystemName(); - } - - // Get the title - String title = blog.getTitle(); - - try - { - JSONWriter jsonWriter = new JSONStringer() - .object() - .key(TITLE).value(title) - .key(PAGE).value(page); - - if (nodeRef != null) - { - // ALF-10182: the nodeRef needs to be included in the activity - // post to ensure read permissions are respected. - jsonWriter.key(PostLookup.JSON_NODEREF).value(nodeRef.toString()); - } - - String data = jsonWriter.endObject().toString(); - - activityService.postActivity( - "org.alfresco.blog.post-" + event, - site.getShortName(), - "blog", data); - } - catch(Exception e) - { - // Warn, but carry on - logger.warn("Error adding blog post " + event + " to activities feed", e); - } - } - - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - Map templateVars = req.getServiceMatch().getTemplateVars(); - if (templateVars == null) - { - String error = "No parameters supplied"; - throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); - } - - - // Parse the JSON, if supplied - JSONObject json = null; - String contentType = req.getContentType(); - if (contentType != null && contentType.indexOf(';') != -1) - { - contentType = contentType.substring(0, contentType.indexOf(';')); - } - if (MimetypeMap.MIMETYPE_JSON.equals(contentType)) - { - JSONParser parser = new JSONParser(); - try - { - json = (JSONObject)parser.parse(req.getContent().getContent()); - } - catch (IOException io) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + io.getMessage()); - } - catch (ParseException pe) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid JSON: " + pe.getMessage()); - } - } - - - // Did they request it by node reference or site? - NodeRef nodeRef = null; - SiteInfo site = null; - BlogPostInfo blog = null; - - if (templateVars.containsKey("site")) - { - // Site, and Optionally Blog Post - String siteName = templateVars.get("site"); - site = siteService.getSite(siteName); - if (site == null) - { - String error = "Could not find site: " + siteName; - throw new WebScriptException(Status.STATUS_NOT_FOUND, error); - } - - // Did they give a blog post name too? - if (templateVars.containsKey("path")) - { - String name = templateVars.get("path"); - blog = blogService.getBlogPost(siteName, name); - - if (blog == null) - { - String error = "Could not find blog '" + name + "' for site '" + - site.getShortName() + "'"; - throw new WebScriptException(Status.STATUS_NOT_FOUND, error); - } - nodeRef = blog.getNodeRef(); - } - else - { - // The NodeRef is the container (if it exists) - if (siteService.hasContainer(siteName, BlogServiceImpl.BLOG_COMPONENT)) - { - nodeRef = siteService.getContainer(siteName, BlogServiceImpl.BLOG_COMPONENT); - } - } - } - else if (templateVars.containsKey("store_type") && - templateVars.containsKey("store_id") && - templateVars.containsKey("id")) - { - // NodeRef, should be a Blog Post - StoreRef store = new StoreRef( - templateVars.get("store_type"), - templateVars.get("store_id")); - - nodeRef = new NodeRef(store, templateVars.get("id")); - if (! nodeService.exists(nodeRef)) - { - String error = "Could not find node: " + nodeRef; - throw new WebScriptException(Status.STATUS_NOT_FOUND, error); - } - - // Try to build the appropriate object for it - blog = blogService.getForNodeRef(nodeRef); - - // See if it's actually attached to a site - if (blog != null) - { - NodeRef container = blog.getContainerNodeRef(); - if (container != null) - { - NodeRef maybeSite = nodeService.getPrimaryParent(container).getParentRef(); - if (maybeSite != null) - { - // Try to make it a site, will return Null if it isn't one - site = siteService.getSite(maybeSite); - } - } - } - } - else - { - String error = "Unsupported template parameters found"; - throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); - } - - // Have the real work done - return executeImpl(site, nodeRef, blog, req, json, status, cache); - } - - protected abstract Map executeImpl(SiteInfo site, - NodeRef nodeRef, BlogPostInfo blog, WebScriptRequest req, - JSONObject json, Status status, Cache cache); -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/BlogLibJs.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/BlogLibJs.java deleted file mode 100644 index 4759c7fce2..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/BlogLibJs.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.BlogIntegrationModel; -import org.alfresco.service.namespace.QName; -import org.json.simple.JSONObject; - -/** - * This class is a port of a previous JavaScript library. - * - * @author Neil Mc Erlean (based on previous JavaScript) - * @since 4.0 - * @deprecated This class should not be extended or reused as it may be refactored. - */ -public class BlogLibJs -{ - /** - * Fetches the blog properties from the json object and adds them to an array - * using the correct property names as indexes. - */ - public static Map getBlogPropertiesArray(JSONObject json) - { - Map arr = new HashMap(); - - putJSONEntryInMap(json, arr, "blogType", BlogIntegrationModel.PROP_BLOG_IMPLEMENTATION); - putJSONEntryInMap(json, arr, "blogId", BlogIntegrationModel.PROP_ID); - putJSONEntryInMap(json, arr, "blogName", BlogIntegrationModel.PROP_NAME); - putJSONEntryInMap(json, arr, "blogDescription", BlogIntegrationModel.PROP_DESCRIPTION); - putJSONEntryInMap(json, arr, "blogUrl", BlogIntegrationModel.PROP_URL); - putJSONEntryInMap(json, arr, "username", BlogIntegrationModel.PROP_USER_NAME); - putJSONEntryInMap(json, arr, "password", BlogIntegrationModel.PROP_PASSWORD); - return arr; - } - - private static void putJSONEntryInMap(JSONObject json, - Map arr, String jsonKey, QName mapKey) - { - if (json.containsKey(jsonKey)) - { - arr.put(mapKey, (Serializable)json.get(jsonKey)); - } - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/BlogPostLibJs.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/BlogPostLibJs.java deleted file mode 100644 index 7e818eeee4..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/BlogPostLibJs.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs; - -import java.io.Serializable; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.BlogIntegrationModel; -import org.alfresco.model.ContentModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * This class is a port of a previous JavaScript library. - * - * @author Neil Mc Erlean (based on previous JavaScript) - * @since 4.0 - */ -public class BlogPostLibJs -{ - //FIXME It will be refactored when the other services are ported from JavaScript to Java. - - /** - * Checks whether a blog configuration is available - * This should at some point also check whether the configuration is enabled. - * - * @param node the node that should be checked. Will check all parents if - * the node itself doesn't contain a configuration. - * @return {boolean} whether a configuration could be found. - */ - public static boolean hasExternalBlogConfiguration(NodeRef node, ServiceRegistry services) - { - if (node == null) - { - return false; - } - else if (services.getNodeService().hasAspect(node, BlogIntegrationModel.ASPECT_BLOG_DETAILS)) - { - return true; - } - else - { - return hasExternalBlogConfiguration(services.getNodeService().getPrimaryParent(node).getParentRef(), services); - } - } - - public static Map getBlogPostData(NodeRef node, ServiceRegistry services) - { - Map data = new HashMap(); - data.put("node", node); - String creator = (String)services.getNodeService().getProperty(node, ContentModel.PROP_CREATOR); - //ALF-18527 - NodeRef person = services.getPersonService().getPersonOrNull(creator); - if (person != null) - { - data.put("author", person); - } - - data.put("commentCount", CommentsLibJs.getCommentsCount(node, services)); - - // is the post published - Serializable published = services.getNodeService().getProperty(node, ContentModel.PROP_PUBLISHED); - boolean isPublished = published != null; - if (isPublished) - { - data.put("releasedDate", published); - } - - // draft - data.put("isDraft", !isPublished); - - // set the isUpdated flag - Date updatedDate = (Date) services.getNodeService().getProperty(node, ContentModel.PROP_UPDATED); - boolean isUpdated = updatedDate != null; - data.put("isUpdated", isUpdated); - if (isUpdated) - { - data.put("updatedDate", updatedDate); - } - - // fetch standard created/modified dates - data.put("createdDate", services.getNodeService().getProperty(node, ContentModel.PROP_CREATED)); - data.put("modifiedDate", services.getNodeService().getProperty(node, ContentModel.PROP_MODIFIED)); - - // does the external post require an update? - Date lastUpdate = (Date) services.getNodeService().getProperty(node, BlogIntegrationModel.PROP_LAST_UPDATE); - if (isPublished && lastUpdate != null) - { - // we either use the release or updated date - Date modifiedDate = (Date) data.get("releasedDate"); - - if (isUpdated) - { - modifiedDate = (Date) data.get("updatedDate"); - } - data.put("outOfDate", modifiedDate.getTime() - lastUpdate.getTime() > 5000L); - } - else - { - data.put("outOfDate", false); - } - - data.put("tags", services.getTaggingService().getTags(node)); - - return data; - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/CommentsLibJs.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/CommentsLibJs.java deleted file mode 100644 index 1da8eea028..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/CommentsLibJs.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs; - -import java.util.ArrayList; -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.model.ForumModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * This class is a port of a previous JavaScript library used by the blog webscript containers. - * - * @author Neil Mc Erlean (based on existing JavaScript code) - * @since 4.0 - */ -class CommentsLibJs -{ - // TODO It will likely be refactored into the Blog REST API class framework. - - private static final String COMMENTS_TOPIC_NAME = "Comments"; - - public static int getCommentsCount(NodeRef node, ServiceRegistry services) - { - return getComments(node, services).size(); - } - - /** - * Returns all comment nodes for a given node. - * @return an array of comments. - */ - public static List getComments(NodeRef node, ServiceRegistry services) - { - List result = new ArrayList(); - - NodeRef commentsFolder = getCommentsFolder(node, services); - if (commentsFolder != null) - { - List children = services.getNodeService().getChildAssocs(commentsFolder, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); - if (!children.isEmpty()) - { - result = children; - } - } - - return result; - } - - /** - * Returns the folder that contains all the comments. - * - * We currently use the fm:discussable aspect where we - * add a "Comments" topic to it. - */ - public static NodeRef getCommentsFolder(NodeRef node, ServiceRegistry services) - { - //FIXME These methods are from the original JavaScript. Should use the (soon to arrive) CommentService. - NodeRef result = null; - if (services.getNodeService().hasAspect(node, ForumModel.ASPECT_DISCUSSABLE)) - { - List forumFolders = services.getNodeService().getChildAssocs(node, ForumModel.ASSOC_DISCUSSION, RegexQNamePattern.MATCH_ALL); - // The JavaScript was retrieving the first child under this child-assoc so we'll do the same. - NodeRef forumFolder = forumFolders.get(0).getChildRef(); - - List 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/src/main/java/org/alfresco/repo/web/scripts/blogs/blog/BlogGet.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/blog/BlogGet.java deleted file mode 100644 index 6cf3bd9732..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/blog/BlogGet.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -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.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.json.simple.JSONObject; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -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(SiteInfo site, NodeRef containerNodeRef, - BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) - { - if (blog != null) - { - // They appear to have supplied a blog post itself... - // Oh well, let's hope for the best! - } - - if (containerNodeRef == null && site != null) - { - // They want to know about a blog container on a - // site where nothing has lazy-created the container - // Give them info on the site for now, should be close enough! - containerNodeRef = site.getNodeRef(); - } - - if (containerNodeRef == null) - { - // Looks like they've asked for something that isn't there - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Blog Not Found"); - } - - // Build the response - // (For now, we just supply the noderef, but when we have a - // proper blog details object we'll use that) - Map model = new HashMap(); - model.put(ITEM, containerNodeRef); - - return model; - } -} \ No newline at end of file diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java deleted file mode 100644 index e3a01ebd2b..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/blog/BlogPut.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.blog; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.BlogIntegrationModel; -import org.alfresco.repo.blog.BlogServiceImpl; -import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript; -import org.alfresco.repo.web.scripts.blogs.BlogLibJs; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.namespace.QName; -import org.json.simple.JSONObject; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * This class is the controller for the blog.put web script. - * - * TODO Push most of the logic from this into the BlogService - * - * @author Neil Mc Erlean (based on existing JavaScript webscript controllers) - * @since 4.0 - */ -public class BlogPut extends AbstractBlogWebScript -{ - @Override - protected Map executeImpl(SiteInfo site, NodeRef containerNodeRef, - BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) - { - if (blog != null) - { - // They appear to have supplied a blog post itself... - // Oh well, let's hope for the best! - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Blog post should not be updated via this web script."); - } - - if (site != null && containerNodeRef == null) - { - // Force the lazy creation - // This is a bit icky, but it'll have to do for now... - containerNodeRef = siteService.createContainer( - site.getShortName(), BlogServiceImpl.BLOG_COMPONENT, null, null); - } - - // Do the work - updateBlog(containerNodeRef, json); - - // Record it as done - Map model = new HashMap(); - model.put("item", containerNodeRef); - - 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)) - { - Map properties = nodeService.getProperties(node); - properties.putAll(arr); - nodeService.setProperties(node, properties); - } - else - { - nodeService.addAspect(node, BlogIntegrationModel.ASPECT_BLOG_DETAILS, arr); - } - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostDelete.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostDelete.java deleted file mode 100644 index 2c492101db..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostDelete.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.post; - -import java.text.MessageFormat; -import java.util.HashMap; -import java.util.Map; -import java.util.ResourceBundle; - -import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.json.simple.JSONObject; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -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 -{ - protected static final String MSG_BLOG_DELETED = "blog-post.msg.deleted"; - - @Override - protected Map executeImpl(SiteInfo site, NodeRef nodeRef, - BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) - { - final ResourceBundle rb = getResources(); - - if (blog == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Blog Post Not Found"); - } - - // TODO Get this from the BlogPostInfo Object - final boolean isDraftBlogPost = blogService.isDraftBlogPost(blog.getNodeRef()); - - // Have it deleted - blogService.deleteBlogPost(blog); - - // If we're in a site, and it isn't a draft, add an activity - if (site != null && !isDraftBlogPost) - { - addActivityEntry("deleted", blog, site, req, json, nodeRef); - } - - // Report it as deleted - Map model = new HashMap(); - String message = rb.getString(MSG_BLOG_DELETED); - model.put("message",MessageFormat.format(message, blog.getNodeRef())); - return model; - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostGet.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostGet.java deleted file mode 100644 index 1e3f0f8151..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/post/BlogPostGet.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -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.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.json.simple.JSONObject; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -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 -{ - @Override - protected Map executeImpl(SiteInfo site, NodeRef nodeRef, - BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) - { - if (blog == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Blog Post Not Found"); - } - - // Build the response - Map model = new HashMap(); - - // TODO Fetch this from the BlogPostInfo object - NodeRef node = blog.getNodeRef(); - Map item = BlogPostLibJs.getBlogPostData(node, services); - model.put(ITEM, item); - model.put(POST, blog); - - 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/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/AbstractGetBlogWebScript.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/AbstractGetBlogWebScript.java deleted file mode 100644 index 2f9a8ec077..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/AbstractGetBlogWebScript.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -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.model.ContentModel; -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript; -import org.alfresco.repo.web.scripts.blogs.BlogPostLibJs; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.blog.BlogService.RangedDateProperty; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.util.Pair; -import org.alfresco.util.ScriptPagingDetails; -import org.alfresco.util.UrlUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONObject; -import org.springframework.extensions.surf.util.URLDecoder; -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 -{ - private static final Log log = LogFactory.getLog(AbstractGetBlogWebScript.class); - - @Override - protected Map executeImpl(SiteInfo site, NodeRef nonSiteContainer, - BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) - { - Map model = new HashMap(); - - // process additional parameters. - PagingRequest pagingReq = parsePagingParams(req); - pagingReq.setRequestTotalCountMax(pagingReq.getSkipCount() + pagingReq.getRequestTotalCountMax()); - - // 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; - } - else - { - // Tags can be full unicode strings, so decode - tag = URLDecoder.decode(tag); - } - - // 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 long 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(site, nonSiteContainer, fromDate, toDate, tag, pagingReq); - - // We need the container for various bits - NodeRef container = nonSiteContainer; - if(container == null) - { - // Container mustn't exist yet - // Fake it with the site for permissions checking reasons - container = site.getNodeRef(); - } - - if (log.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Retrieved ").append(blogPostList.getPage().size()).append(" blog posts in page."); - log.debug(msg.toString()); - } - - createFtlModel(req, model, container, 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(); - int total = blogPostList.getPage().size(); - if (totalResultCount != null && totalResultCount.getFirst() != null) - { - total = totalResultCount.getFirst(); - } - //FIXME What to do? null - blogPostsData.put("total", total); - blogPostsData.put("pageSize", pagingReq.getMaxItems()); - blogPostsData.put("startIndex", pagingReq.getSkipCount()); - blogPostsData.put("itemCount", blogPostList.getPage().size()); - - if (total == pagingReq.getRequestTotalCountMax()) - { - blogPostsData.put("totalRecordsUpper", true); - } - else - { - blogPostsData.put("totalRecordsUpper", false); - } - - List> blogPostDataSets = new ArrayList>(blogPostList.getPage().size()); - for (BlogPostInfo postInfo : blogPostList.getPage()) - { - Map data = BlogPostLibJs.getBlogPostData(postInfo.getNodeRef(), services); - blogPostDataSets.add(data); - } - blogPostsData.put("items", blogPostDataSets); - - model.put("data", blogPostsData); - - // fetch the contentLength param - String contentLengthStr = req.getParameter("contentLength"); - int contentLength = contentLengthStr == null ? -1 : Integer.parseInt(contentLengthStr); - model.put("contentLength", contentLength); - - // assign the blog node - model.put("blog", node); - model.put("externalBlogConfig", BlogPostLibJs.hasExternalBlogConfiguration(node, services)); - } - - private PagingRequest parsePagingParams(WebScriptRequest req) - { - return ScriptPagingDetails.buildPagingRequest(req, 1000); - } - - private Date parseDateParam(WebScriptRequest req, String paramName) - { - Map templateVars = req.getServiceMatch().getTemplateVars(); - String dateStr = templateVars.get(paramName); - if(dateStr == null) - { - // Try on the parameters instead - dateStr = req.getParameter(paramName); - } - - // Parse if available - Date result = null; - if (dateStr != null) - { - result = new Date(Long.parseLong(dateStr)); - } - return result; - } - - - /** - * Fetches all posts of the given blog - */ - private PagingResults getBlogPostList(SiteInfo site, NodeRef nonSiteContainer, - Date fromDate, Date toDate, String tag, PagingRequest pagingReq) - { - // Currently we only support CannedQuery-based gets without tags: - if (tag == null || tag.trim().isEmpty()) - { - return getBlogResultsImpl(site, nonSiteContainer, fromDate, toDate, pagingReq); - } - else - { - RangedDateProperty dateRange = new RangedDateProperty(fromDate, toDate, ContentModel.PROP_CREATED); - if(site != null) - { - return blogService.findBlogPosts(site.getShortName(), dateRange, tag, pagingReq); - } - else - { - return blogService.findBlogPosts(nonSiteContainer, dateRange, tag, pagingReq); - } - } - } - - protected abstract PagingResults getBlogResultsImpl( - SiteInfo site, NodeRef nonSiteContainer, Date fromDate, Date toDate, PagingRequest pagingReq); -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsGet.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsGet.java deleted file mode 100644 index 8d38f0bdc8..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsGet.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.posts; - -import java.util.Date; - -import org.alfresco.query.EmptyPagingResults; -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; - -/** - * 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 BlogPostsGet extends AbstractGetBlogWebScript -{ - @SuppressWarnings("deprecation") - @Override - protected PagingResults getBlogResultsImpl( - SiteInfo site, NodeRef node, Date fromDate, Date toDate, PagingRequest pagingReq) - { - // As it uses deprecated methods, this bit can be a bit hacky... - if (node == null) - { - // Site based request, but no container exists yet - return new EmptyPagingResults(); - } - - // This intentionally uses the deprecated method in the foundation service. - // In fact the method is there specifically for this class. - return blogService.getMyDraftsAndAllPublished(node, fromDate, toDate, pagingReq); - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsMyDraftsGet.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsMyDraftsGet.java deleted file mode 100644 index 3152c8390c..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsMyDraftsGet.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.posts; - -import java.util.Date; - -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; - -/** - * This class is the controller for the blog-posts-mydrafts.get web script. - * Based on the original JavaScript webscript controller - * - * @author Neil Mc Erlean (based on existing JavaScript webscript controllers) - * @since 4.0 - */ -public class BlogPostsMyDraftsGet extends AbstractGetBlogWebScript -{ - @Override - protected PagingResults getBlogResultsImpl(SiteInfo site, NodeRef node, Date fromDate, Date toDate, PagingRequest pagingReq) - { - String user = AuthenticationUtil.getFullyAuthenticatedUser(); - if(site != null) - { - return blogService.getDrafts(site.getShortName(), user, pagingReq); - } - else - { - return blogService.getDrafts(node, user, pagingReq); - } - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsMyPublishedGet.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsMyPublishedGet.java deleted file mode 100644 index d226a12fc4..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsMyPublishedGet.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.posts; - -import java.util.Date; - -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; - -/** - * This class is the controller for the blog-posts-mypublished.get web script. - * - * @author Neil Mc Erlean (based on existing JavaScript webscript controllers) - * @since 4.0 - */ -public class BlogPostsMyPublishedGet extends AbstractGetBlogWebScript -{ - @Override - protected PagingResults getBlogResultsImpl( - SiteInfo site, NodeRef node, Date fromDate, Date toDate, PagingRequest pagingReq) - { - String fullyAuthenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser(); - if(site != null) - { - return blogService.getPublished(site.getShortName(), fromDate, toDate, fullyAuthenticatedUser, pagingReq); - } - else - { - return blogService.getPublished(node, fromDate, toDate, fullyAuthenticatedUser, pagingReq); - } - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsNewGet.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsNewGet.java deleted file mode 100644 index 2166418dcf..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsNewGet.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.posts; - -import java.util.Date; - -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; - -/** - * This class is the controller for the blog-posts-publishedext.get web script. - * - * @author Neil Mc Erlean (based on existing JavaScript webscript controllers) - * @since 4.0 - */ -public class BlogPostsNewGet extends AbstractGetBlogWebScript -{ - @Override - protected PagingResults getBlogResultsImpl( - SiteInfo site, NodeRef node, Date fromDate, Date toDate, PagingRequest pagingReq) - { - if(site != null) - { - return blogService.getPublished(site.getShortName(), fromDate, toDate, null, pagingReq); - } - else - { - return blogService.getPublished(node, fromDate, toDate, null, pagingReq); - } - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPerMonthGet.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPerMonthGet.java deleted file mode 100644 index 7b45916e9c..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPerMonthGet.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.posts; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.model.ContentModel; -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.springframework.extensions.webscripts.WebScriptRequest; - -/** - * This class is the controller for the blog-posts-mypublished.get web script. - * - * @author Neil Mc Erlean (based on existing JavaScript webscript controllers) - * @since 4.0 - */ -public class BlogPostsPerMonthGet extends AbstractGetBlogWebScript -{ - @Override - protected PagingResults getBlogResultsImpl( - SiteInfo site, NodeRef node, Date fromDate, Date toDate, PagingRequest pagingReq) - { - if(site != null) - { - return blogService.getPublished(site.getShortName(), fromDate, toDate, null, pagingReq); - } - else - { - return blogService.getPublished(node, fromDate, toDate, null, pagingReq); - } - } - - @Override - protected void createFtlModel(WebScriptRequest req, Map model, NodeRef node, PagingRequest pagingReq, PagingResults blogPostList) - { - model.put(DATA, getBlogPostMonths(blogPostList)); - } - - - /** - * Ported from blog-posts-per-month.get.js - */ - @SuppressWarnings("deprecation") - private Date getBeginOfMonthDate(Date date) - { - //TODO These date processing methods are copied almost verbatim from JavaScript to preserve behaviour. - // However they should be updated to use java.util.Calendar as the current implementation assumes a Gregorian calendar. - Calendar calendar = Calendar.getInstance(); - calendar.set(date.getYear(), date.getMonth(), 1); - return calendar.getTime(); - } - - /** - * Returns the date representing the last second of a month (23:59:59) - * Ported from blog-posts-per-month.get.js - */ - @SuppressWarnings("deprecation") - private Date getEndOfMonthDate(Date date) - { - Calendar calendar = Calendar.getInstance(); - calendar.set(date.getYear(), date.getMonth(), date.getDay()); - // In Gregorian calendar, this would be 31 for January, 30 for March, 28 or 29 for February. - int lastDayOfSpecifiedMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); - calendar.set(date.getYear(), date.getMonth(), lastDayOfSpecifiedMonth, 23, 59, 59); - - return calendar.getTime(); - } - - /** - * Create an object containing information about the month specified by date. - * Ported from blog-posts-per-month.get.js - */ - @SuppressWarnings("deprecation") - private Map getMonthDataObject(Date date) - { - Map data = new HashMap(); - data.put("year", date.getYear() + 1900); - data.put("month", date.getMonth()); - data.put("firstPostInMonth", date); - data.put("beginOfMonth", getBeginOfMonthDate(date)); - data.put("endOfMonth", getEndOfMonthDate(date)); - data.put("count", 1); - - return data; - } - - /** - * Fetches data for each month for which posts exist, plus the count of each. - * Note: If no posts could be found, this method will return the current month - * but with a count of posts equals zero. - * Ported from blog-posts-per-month.get.js - */ - @SuppressWarnings("deprecation") - private List> getBlogPostMonths(PagingResults nodes) - { - // will hold the months information - List> data = new ArrayList>(); - - // do we have posts? - if (!nodes.getPage().isEmpty()) - { - int currYear = -1; - int currMonth = -1; - Map currData = null; - for (int x = 0; x < nodes.getPage().size(); x++) - { - NodeRef node = nodes.getPage().get(x).getNodeRef(); - Date date = (Date) nodeService.getProperty(node, ContentModel.PROP_PUBLISHED); - - // is this a new month? - if (currYear != date.getYear() + 1900 || currMonth != date.getMonth()) - { - currYear = date.getYear() + 1900; - currMonth = date.getMonth(); - currData = getMonthDataObject(date); - data.add(currData); - } - // otherwise just increment the counter - else - { - Object countObj = currData.get("count"); - Integer countInt = countObj == null ? 0 : (Integer)countObj; - - currData.put("count", countInt + 1); - } - } - } - // if not, add the current month with count = 0 - else - { - Map emptyData = getMonthDataObject(new Date()); - emptyData.put("count", 0); - data.add(emptyData); - } - - return data; - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPost.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPost.java deleted file mode 100644 index 0cd2843f7d..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPost.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.posts; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.web.scripts.blogs.AbstractBlogWebScript; -import org.alfresco.repo.web.scripts.blogs.BlogPostLibJs; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.tagging.TaggingService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -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.post web script. - * - * @author Neil Mc Erlean (based on existing JavaScript webscript controllers) - * @since 4.0 - */ -public class BlogPostsPost extends AbstractBlogWebScript -{ - private static final Log log = LogFactory.getLog(BlogPostsPost.class); - - // Injected services - private TaggingService taggingService; - - public void setTaggingService(TaggingService taggingService) - { - this.taggingService = taggingService; - } - - @Override - protected Map executeImpl(SiteInfo site, NodeRef nodeRef, - BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) - { - Map model = new HashMap(); - - // If they're doing Path Based rather than Site Based, ensure - // that the Container is a Tag Scope - if(site == null && nodeRef != null) - { - ensureTagScope(nodeRef); - } - - // Have the Blog Post created - JsonParams jsonPostParams = parsePostParams(json); - BlogPostInfo post = createBlogPost(jsonPostParams, site, nodeRef); - - Map blogPostData = BlogPostLibJs.getBlogPostData(post.getNodeRef(), services); - model.put(ITEM, blogPostData); - model.put(EXTERNAL_BLOG_CONFIG, BlogPostLibJs.hasExternalBlogConfiguration(nodeRef, services)); - - boolean isDraft = blogPostData.get("isDraft") != null && - ((Boolean)blogPostData.get("isDraft")).booleanValue(); - if (jsonPostParams.getSite() != null && - jsonPostParams.getContainer() != null && - jsonPostParams.getPage() != null && - !isDraft) - { - addActivityEntry("created", post, site, req, json, post.getNodeRef()); - } - - return model; - } - - private JsonParams parsePostParams(JSONObject json) - { - JsonParams result = new JsonParams(); - if (json.containsKey(TITLE)) - { - result.setTitle((String)json.get(TITLE)); - } - if (json.containsKey(CONTENT)) - { - result.setContent((String)json.get(CONTENT)); - } - if (json.containsKey(DRAFT)) - { - Object draft = json.get(DRAFT); - if (draft instanceof Boolean) - { - result.setIsDraft((Boolean)draft); - } - else - { - result.setIsDraft( Boolean.parseBoolean((String)draft) ); - } - } - - // If there are no tags, this is a java.lang.String "". - // If there are any tags, it's a JSONArray of strings. One or more. - if (json.containsKey(TAGS)) - { - Object tagsObj = json.get(TAGS); - List tags = new ArrayList(); - if (tagsObj instanceof JSONArray) - { - JSONArray tagsJsonArray = (JSONArray)tagsObj; - for (int i = 0; i < tagsJsonArray.size(); i++) - { - tags.add( (String)tagsJsonArray.get(i) ); - } - } - else - { - tags.add(tagsObj.toString()); - } - result.setTags(tags); - } - if (json.containsKey(SITE)) - { - result.setSite((String)json.get(SITE)); - } - if (json.containsKey(PAGE)) - { - result.setPage((String)json.get(PAGE)); - } - if (json.containsKey(CONTAINER)) - { - result.setContainer((String)json.get(CONTAINER)); - } - - return result; - } - - /** - * Taken from JS - * @param node NodeRef - */ - private void ensureTagScope(NodeRef node) - { - if (!taggingService.isTagScope(node)) - { - taggingService.addTagScope(node); - } - - - // also check the parent (the site!) - NodeRef parent = nodeService.getPrimaryParent(node).getParentRef(); - if (!taggingService.isTagScope(parent)) - { - taggingService.addTagScope(parent); - } - } - - /** - * Creates a blog post - */ - private BlogPostInfo createBlogPost(JsonParams jsonParams, SiteInfo site, NodeRef blogNode) - { - String titleParam = jsonParams.getTitle() == null ? "" : jsonParams.getTitle(); - String contentParam = jsonParams.getContent() == null ? "" : jsonParams.getContent(); - boolean isDraftParam = jsonParams.getIsDraft(); - - if (log.isDebugEnabled()) - { - StringBuilder msg = new StringBuilder(); - msg.append("Creating blog-post '").append(titleParam).append("'"); - if (isDraftParam) - { - msg.append(" DRAFT"); - } - log.debug(msg.toString()); - } - - List tagsParam = new ArrayList(); - if (jsonParams.getTags() != null) - { - tagsParam.addAll(jsonParams.getTags()); - } - - BlogPostInfo newPostNode; - if(site != null) - { - newPostNode = blogService.createBlogPost( - site.getShortName(), titleParam, contentParam, isDraftParam); - } - else - { - newPostNode = blogService.createBlogPost( - blogNode, titleParam, contentParam, isDraftParam); - } - - // Ignore empty string tags - List nonEmptyTags = new ArrayList(); - for (String tag : tagsParam) - { - if (!tag.trim().isEmpty()) - { - nonEmptyTags.add(tag); - } - } - if (!nonEmptyTags.isEmpty()) - { - taggingService.setTags(newPostNode.getNodeRef(), nonEmptyTags); - } - - return newPostNode; - } - - /** - * A simple POJO class for the parsed JSON from the POST body. - */ - class JsonParams - { - private String title; - private String content; - private boolean isDraft = false; - private List tags; - private String site; - private String container; - private String page; - - public String getTitle() - { - return title; - } - public void setTitle(String title) - { - this.title = title; - } - public String getContent() - { - return content; - } - public void setContent(String content) - { - this.content = content; - } - public boolean getIsDraft() - { - return isDraft; - } - public void setIsDraft(boolean isDraft) - { - this.isDraft = isDraft; - } - public List getTags() - { - return tags; - } - public void setTags(List tags) - { - this.tags = tags; - } - public String getSite() - { - return site; - } - public void setSite(String site) - { - this.site = site; - } - public String getContainer() - { - return container; - } - public void setContainer(String container) - { - this.container = container; - } - public String getPage() - { - return page; - } - public void setPage(String page) - { - this.page = page; - } - } -} diff --git a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPublishedExtGet.java b/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPublishedExtGet.java deleted file mode 100644 index d8b54ce5c1..0000000000 --- a/src/main/java/org/alfresco/repo/web/scripts/blogs/posts/BlogPostsPublishedExtGet.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs.posts; - -import java.util.Date; - -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.service.cmr.blog.BlogPostInfo; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.site.SiteInfo; - -/** - * This class is the controller for the blog-posts-publishedext.get web script. - * - * @author Neil Mc Erlean (based on existing JavaScript webscript controllers) - * @since 4.0 - */ -public class BlogPostsPublishedExtGet extends AbstractGetBlogWebScript -{ - @Override - protected PagingResults getBlogResultsImpl( - SiteInfo site, NodeRef node, Date fromDate, Date toDate, PagingRequest pagingReq) - { - if(site != null) - { - return blogService.getPublishedExternally(site.getShortName(), pagingReq); - } - else - { - return blogService.getPublishedExternally(node, pagingReq); - } - } -} diff --git a/src/main/resources/alfresco/blogs/web-scripts-blog-context.xml b/src/main/resources/alfresco/blogs/web-scripts-blog-context.xml deleted file mode 100644 index ee43c630ce..0000000000 --- a/src/main/resources/alfresco/blogs/web-scripts-blog-context.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-created.atomentry.ftl b/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-created.atomentry.ftl deleted file mode 100644 index 86fd85a509..0000000000 --- a/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-created.atomentry.ftl +++ /dev/null @@ -1,14 +0,0 @@ -<#include "../slingshot-common.lib.ftl"> - - Blog post created: ${htmlTitle?xml} - - http://www.alfresco.org/rss/atom/${id} - ${xmldate(date)} - - - - - ${userName?xml} - ${userId?xml} - - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-deleted.atomentry.ftl b/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-deleted.atomentry.ftl deleted file mode 100644 index 81a56348ec..0000000000 --- a/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-deleted.atomentry.ftl +++ /dev/null @@ -1,14 +0,0 @@ -<#include "../slingshot-common.lib.ftl"> - - Blog post deleted: ${htmlTitle?xml} - - http://www.alfresco.org/rss/atom/${id} - ${xmldate(date)} - - - - - ${userName?xml} - ${userId?xml} - - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-updated.atomentry.ftl b/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-updated.atomentry.ftl deleted file mode 100644 index 8c9cc18456..0000000000 --- a/src/main/resources/alfresco/templates/activities/org/alfresco/blog/post-updated.atomentry.ftl +++ /dev/null @@ -1,14 +0,0 @@ -<#include "../slingshot-common.lib.ftl"> - - Blog post updated: ${htmlTitle?xml} - - http://www.alfresco.org/rss/atom/${id} - ${xmldate(date)} - - - - - ${userName?xml} - ${userId?xml} - - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog.lib.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog.lib.ftl deleted file mode 100644 index f5e782617c..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog.lib.ftl +++ /dev/null @@ -1,31 +0,0 @@ -<#-- - This template renders the blog data object. ---> -<#macro blogJSON item> -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "qnamePath": "${item.qnamePath}", - "detailsUrl": "blog/node/${item.nodeRef?replace('://', '/')}", - "blogPostsUrl": "blog/node/${item.nodeRef?replace('://', '/')}/posts", - "type": "${item.properties["blg:blogImplementation"]!''}", - "id": "${item.properties["blg:id"]!'0'}", - "name": "${item.properties["blg:name"]!''}", - "description": "${item.properties["blg:description"]!''}", - "url": "${item.properties["blg:url"]!''}", - "username": "${item.properties["blg:userName"]!''}", - "password": "${item.properties["blg:password"]!''}", - "permissions": - { - <#if item.getParent()?? && item.getTypeShort() != "st:site" > - "create": ${(item.getParent()).hasPermission("CreateChildren")?string}, - "edit": ${(item.getParent()).hasPermission("Write")?string}, - "delete": ${(item.getParent()).hasPermission("Delete")?string} - <#else> - "create": ${item.hasPermission("CreateChildren")?string}, - "edit": ${item.hasPermission("Write")?string}, - "delete": ${item.hasPermission("Delete")?string} - - } -} - - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog.lib.js b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog.lib.js deleted file mode 100644 index 56f265d812..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog.lib.js +++ /dev/null @@ -1,49 +0,0 @@ - -/** Name of the blog details aspect. */ -const BLOG_DETAILS_ASPECT = "blg:blogDetails"; - -/** - * Fetches the blog properties from the json object and adds them to an array - * using the correct property names as indexes. - */ -function getBlogPropertiesArray() -{ - var arr = new Array(); - if (json.has("blogType")) - { - arr["blg:blogImplementation"] = json.get("blogType"); - } - if (json.has("blogId")) - { - arr["blg:id"] = json.get("blogId"); - } - if (json.has("blogName")) - { - arr["blg:name"] = json.get("blogName"); - } - if (json.has("blogDescription")) - { - arr["blg:description"] = json.get("blogDescription"); - } - if (json.has("blogUrl")) - { - arr["blg:url"] = json.get("blogUrl"); - } - if (json.has("username")) - { - arr["blg:userName"] = json.get("username"); - } - if (json.has("password")) - { - arr["blg:password"] = json.get("password"); - } - return arr; -} - -/** - * Returns the data object of a blog node. - */ -function getBlogData(node) -{ - return node; -} diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.get.desc.xml deleted file mode 100644 index 318ccfff7d..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.get.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Get blog - Get the blog information. - /api/blog/site/{site}/{container}/{path} - /api/blog/site/{site}/{container} - /api/blog/node/{store_type}/{store_id}/{id} - argument - user - required - limited_support - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.get.json.ftl deleted file mode 100644 index cc1616611b..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.get.json.ftl +++ /dev/null @@ -1,4 +0,0 @@ -<#import "../blog.lib.ftl" as blogLib/> -{ - "item" : <@blogLib.blogJSON item=item /> -} diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.put.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.put.desc.xml deleted file mode 100644 index c77db3c4d3..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.put.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Put blog - Updates a blog. - /api/blog/site/{site}/{container}/{path} - /api/blog/site/{site}/{container} - /api/blog/node/{store_type}/{store_id}/{id} - argument - user - required - limited_support - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.put.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.put.json.ftl deleted file mode 100644 index cc1616611b..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blog/blog.put.json.ftl +++ /dev/null @@ -1,4 +0,0 @@ -<#import "../blog.lib.ftl" as blogLib/> -{ - "item" : <@blogLib.blogJSON item=item /> -} diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.ftl deleted file mode 100644 index e56121b762..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.ftl +++ /dev/null @@ -1,116 +0,0 @@ -<#import "../generic-paged-results.lib.ftl" as gen/> - -<#-- Renders a person object. --> -<#macro renderPerson person fieldName> -<#escape x as jsonUtils.encodeJSONString(x)> - "${fieldName}": - { - <#if person.assocs["cm:avatar"]??> - "avatarRef": "${person.assocs["cm:avatar"][0].nodeRef?string}", - - "username": "${person.properties["cm:userName"]}", - "firstName": "${person.properties["cm:firstName"]!""}", - "lastName": "${person.properties["cm:lastName"]!""}" - }, - - - - -<#macro addContent item> -<#escape x as jsonUtils.encodeJSONString(x)> - <#assign safecontent=stringUtils.stripUnsafeHTML(item.node.content)> - <#if (contentLength?? && contentLength > -1 && (safecontent?length > contentLength))> - "content": "${safecontent?substring(0, contentLength)}", - <#else> - "content": "${safecontent}", - - - - -<#-- - This template renders a blog post. ---> -<#macro blogpostJSON item> -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "url": "blog/post/node/${item.node.nodeRef?replace('://','/')}", - "commentsUrl": "/node/${item.node.nodeRef?replace('://','/')}/comments", - "nodeRef": "${item.node.nodeRef}", - "name": "${item.node.properties.name!''}", - "title": "${item.node.properties.title!''}", - <@addContent item=item /> - <#if item.author??> - <@renderPerson person=item.author fieldName="author" /> - <#else> - "author": - { - "username": "${item.node.properties.creator}" - }, - - "createdOn": "${formatDateRFC822(item.createdDate)}", - "modifiedOn": "${formatDateRFC822(item.modifiedDate)}", - "permissions": - { - "edit": ${item.node.hasPermission("Write")?string}, - "delete": ${item.node.hasPermission("Delete")?string} - }, - "commentCount": ${item.commentCount?c}, - "tags": [<#list item.tags as x>"${x}"<#if x_has_next>, ], - <#-- draft vs internal published --> - "isDraft": ${item.isDraft?string}, - <#if (! item.isDraft)> - "releasedOn": "${formatDateRFC822(item.releasedDate)}", - - <#-- true if the post has been updated --> - "isUpdated": ${item.isUpdated?string}, - <#if (item.isUpdated)> - "updatedOn": "${formatDateRFC822(item.updatedDate)}", - - <#if (item.node.properties["blg:published"]?? && item.node.properties["blg:published"] == true)> - "publishedOn": "${formatDateRFC822(item.node.properties["blg:posted"])}", - "updatedOn": "${formatDateRFC822(item.node.properties["blg:lastUpdate"])}", - "postId": "${item.node.properties["blg:postId"]!''}", - "postLink": "${item.node.properties["blg:link"]!''}", - "outOfDate": ${item.outOfDate?string}, - - <#-- external publishing - last to make sure that we correctly end the response without a comma --> - "isPublished": ${(item.node.properties["blg:published"]!'false')?string} -} - - - -<#macro renderPostList> -{ - "metadata": - { - "blogPermissions": - { - "create": ${blog.hasPermission("CreateChildren")?string}, - "edit": ${blog.hasPermission("Write")?string}, - "delete": ${blog.hasPermission("Delete")?string} - }, - "externalBlogConfig": ${externalBlogConfig?string} - }, - "totalRecordsUpper": ${data.totalRecordsUpper?string("true","false")}, -<@gen.pagedResults data=data ; item> - <@blogpostJSON item=item /> - -} - - -<#macro renderPost> -{ - "metadata": - { - "externalBlogConfig": ${externalBlogConfig?string} - }, - "item": <@blogpostJSON item=item /> -} - - -<#function formatDateRFC822 dateItem> - <# local temp=${.locale} --> - <#setting locale="en_US"> - <#return dateItem?datetime?string("EEE, d MMM yyyy HH:mm:ss Z")> - <# setting locale=temp --> - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js deleted file mode 100644 index 3fd174e74d..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js +++ /dev/null @@ -1,130 +0,0 @@ - - -const ASPECT_SYNDICATION = "cm:syndication"; -const PROP_PUBLISHED = "cm:published"; -const PROP_UPDATED = "cm:updated"; - -function setOrUpdateReleasedAndUpdatedDates(node) -{ - // make sure the syndication aspect has been added - if (!node.hasAspect(ASPECT_SYNDICATION)) - { - node.addAspect(ASPECT_SYNDICATION, []); - } - - // (re-)enable permission inheritance which got disable for draft posts - // only set if was previously draft - as only the owner/admin can do this - if (!node.inheritsPermissions()) - { - // MNT-12082 - node.removePermission("All", node.getOwner()); - node.setInheritsPermissions(true); - } - - // check whether the published date has been set - if (!node.properties[PROP_PUBLISHED]) - { - // set the published date - node.properties[PROP_PUBLISHED] = new Date(); - node.save(); - } - else - { - // set/update the updated date - node.properties[PROP_UPDATED] = new Date(); - node.save(); - } -} - -/** - * Returns the data of a blog post. - */ -function getBlogPostData(node) -{ - var data = {}; - data.node = node; - data.author = people.getPerson(node.properties["cm:creator"]); - data.commentCount = getCommentsCount(node); - - // is the post published - var isPublished = (node.properties[PROP_PUBLISHED] !== null); - if (isPublished) - { - data.releasedDate = node.properties[PROP_PUBLISHED]; - } - - // draft - data.isDraft = ! isPublished; - - // set the isUpdated flag - var isUpdated = (node.properties[PROP_UPDATED] !== null); - data.isUpdated = isUpdated; - if (isUpdated) - { - data.updatedDate = node.properties[PROP_UPDATED]; - } - - // fetch standard created/modified dates - data.createdDate = node.properties["cm:created"]; - data.modifiedDate = node.properties["cm:modified"]; - - // does the external post require an update? - if (isPublished && (node.properties["blg:lastUpdate"] !== null)) - { - // we either use the release or updated date - var modifiedDate = data.releasedDate; - if (isUpdated) - { - modifiedDate = data.updatedDate; - } - - if ((modifiedDate - node.properties["blg:lastUpdate"]) > 5000) - { - data.outOfDate = true; - } - else - { - data.outOfDate = false; - } - } - else - { - data.outOfDate = false; - } - - // tags - if (node.tags !== null) - { - data.tags = node.tags; - } - else - { - data.tags = []; - } - - return data; -} - -/** - * Checks whether a blog configuration is available - * This should at some point also check whether the configuration is enabled. - * - * @param node the node that should be checked. Will check all parents if - * the node itself doesn't contain a configuration. - * @return {boolean} whether a configuration could be found. - */ -function hasExternalBlogConfiguration(node) -{ - if (node === null || !node.hasPermission("ReadProperties")) - { - return false; - } - else if (node.hasAspect("blg:blogDetails")) - { - return true; - } - else - { - return hasExternalBlogConfiguration(node.parent); - } -} \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.desc.xml deleted file mode 100644 index 7a6d283a96..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.desc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - Blog post publishing - Performs external blog publishing functions on a blog post. - /api/blog/post/site/{site}/{container}/{path}/publishing - /api/blog/post/node/{store_type}/{store_id}/{id}/publishing - argument - user - required - limited_support - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.json.ftl deleted file mode 100644 index 709882b67f..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPost /> \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.json.js b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.json.js deleted file mode 100644 index 82b2206d71..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post-publishing.post.json.js +++ /dev/null @@ -1,88 +0,0 @@ - - - -const POST_ACTION = "publish"; -const UPDATE_ACTION = "update"; -const REMOVE_ACTION = "unpublish"; - -/** - * Validates the action to execute. - * @return the action name to be used for the blog-post action or null if the specified action is invalid - */ -function validateAction(node, action) -{ - var blogAction = null; - var isPublished = false; - if ((node.hasAspect("blg:blogPost")) && (node.properties["blg:published"] == true)) - { - isPublished = true; - } - - // make sure we have a real JavaScript object, otherwise switch won't work correctly - action = "" + action; - switch (action) - { - case POST_ACTION: - blogAction = (isPublished ? "" : "post"); - break; - case UPDATE_ACTION: - blogAction = (isPublished ? "update" : ""); - break; - case REMOVE_ACTION: - blogAction = (isPublished ? "remove" : ""); - break; - } - - if (blogAction === null) - { - // set an error status - status.setCode(status.STATUS_BAD_REQUEST, "Invalid action specified (node in wrong state?)"); - return null; - } - else - { - return blogAction; - } -} - -/** - * Publishe, update or removes the blog from/to the external blog - */ -function executeAction(node, action) -{ - // get the blog action to call (the names differ from the constants defined above) - var blogAction = validateAction(node, action); - if (blogAction != null) - { - var blog = actions.create("blog-post"); - blog.parameters.action = blogAction; - blog.execute(node); - - // check whether we got an error - if result is non-empty - if (blog.parameters["result"].length > 0) - { - status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, blog.parameters["result"]); - return; - } - } -} - -function main() -{ - // get requested node - var node = getRequestNode(); - if (status.getCode() != status.STATUS_OK) - { - return; - } - - // fetch and execute the action - var action = json.get("action"); - executeAction(node, action); - - // get the updated data for the blog post - model.item = getBlogPostData(node); - model.externalBlogConfig = hasExternalBlogConfiguration(node); -} - -main(); diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.desc.xml deleted file mode 100644 index 2b6aeb36f7..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.desc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - Delete blog post - Deletes a blog post. - /api/blog/post/site/{site}/{container}/{path} - /api/blog/post/node/{store_type}/{store_id}/{id} - argument - user - required - limited_support - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.json.ftl deleted file mode 100644 index 9a22868515..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.json.ftl +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message" : "${message}" -} \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.properties deleted file mode 100644 index 474e147054..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=Blog {0} deleted diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_de.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_de.properties deleted file mode 100755 index 7ac89a6a3a..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_de.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=Blog {0} gel\u00f6scht diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_es.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_es.properties deleted file mode 100755 index 5aadf01515..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_es.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=Blog {0} eliminado diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_fr.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_fr.properties deleted file mode 100755 index a9cc3794ee..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_fr.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=Blog {0} supprim\u00e9 diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_it.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_it.properties deleted file mode 100755 index 528bb1f41e..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_it.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=Blog {0} eliminato diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_ja.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_ja.properties deleted file mode 100755 index 29448bdd3e..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_ja.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=\u30d6\u30ed\u30b0 "{0}" \u304c\u524a\u9664\u3055\u308c\u307e\u3057\u305f diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_nb.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_nb.properties deleted file mode 100755 index 61ea5282e3..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_nb.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=Bloggen {0} ble slettet diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_nl.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_nl.properties deleted file mode 100755 index e391da0445..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_nl.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=Blog {0} verwijderd diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_pt_BR.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_pt_BR.properties deleted file mode 100644 index 764ef85137..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_pt_BR.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=Blog {0} exclu\u00eddo diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_ru.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_ru.properties deleted file mode 100755 index d42a016a30..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_ru.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=\u0411\u043b\u043e\u0433 {0} \u0443\u0434\u0430\u043b\u0435\u043d diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_zh_CN.properties b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_zh_CN.properties deleted file mode 100755 index 6cd3c84da7..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.delete_zh_CN.properties +++ /dev/null @@ -1 +0,0 @@ -blog-post.msg.deleted=\u5df2\u5220\u9664\u535a\u5ba2 {0} diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.get.desc.xml deleted file mode 100644 index 1f95700778..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.get.desc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - Get all blogs - Gets all blogs. - /api/blog/post/site/{site}/{container}/{path} - /api/blog/post/node/{store_type}/{store_id}/{id} - argument - user - required - limited_support - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.get.json.ftl deleted file mode 100644 index 709882b67f..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.get.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPost /> \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.desc.xml deleted file mode 100644 index d5e377c767..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.desc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - Update blog post - Updates a blog post. - /api/blog/post/site/{site}/{container}/{path} - /api/blog/post/node/{store_type}/{store_id}/{id} - argument - user - required - limited_support - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.json.ftl deleted file mode 100644 index 709882b67f..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPost /> \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.json.js b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.json.js deleted file mode 100644 index 4c52114aba..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/post/blog-post.put.json.js +++ /dev/null @@ -1,91 +0,0 @@ - - - -/** - * Updates the draft mode part of the post - */ -function updateBlogPostDraftMode(postNode) -{ - // make sure the user doesn't try to put a non-draft - // post back into draft node - var currentDraft = (postNode.properties[PROP_PUBLISHED] == undefined); - var isDraft = json.has("draft") && json.get("draft").toString() == "true"; - - // requested draft, previously non-draft: throw an exception - if (isDraft && !currentDraft) - { - // set an error - status.setCode(status.STATUS_BAD_REQUEST, "Cannot put a published post back into draft mode"); - return null; - } - - if (!isDraft) - { - setOrUpdateReleasedAndUpdatedDates(postNode); - } -} - -/** - * Updates a blog post node - */ -function updateBlogPost(postNode) -{ - // fetch the new data - var title = ""; - if (json.has("title")) - { - title = json.get("title"); - } - var content = ""; - if (json.has("content")) - { - content = json.get("content"); - } - var tags = []; - if (json.has("tags")) - { - // get the tags JSONArray and copy it into a real javascript array object - var tmp = json.get("tags"); - for (var x=0; x < tmp.length(); x++) - { - tags.push(tmp.get(x)); - } - } - - // update the node - postNode.properties["cm:title"] = title; - postNode.mimetype = "text/html"; - postNode.content = content - postNode.tags = tags; - postNode.save(); - - updateBlogPostDraftMode(postNode); -} - -function main() -{ - // get requested node - var node = getRequestNode(); - if (status.getCode() != status.STATUS_OK) - { - return; - } - - // update blog post - updateBlogPost(node); - - model.item = getBlogPostData(node); - model.externalBlogConfig = hasExternalBlogConfiguration(node); - - if (json.has("site") && json.has("container") && json.has("page") && !model.item.isDraft) - { - var data = - { - title: model.item.node.properties.title, - page: json.get("page") + "?postId=" + model.item.node.properties.name - } - activities.postActivity("org.alfresco.blog.post-updated", json.get("site"), "blog", jsonUtils.toJSONString(data)); - } -} - -main(); diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.desc.xml deleted file mode 100644 index 592b003de7..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Get blog posts (draft) - Gets all draft posts for a blog. - /api/blog/site/{site}/{container}/{path}/posts/mydrafts - /api/blog/site/{site}/{container}/posts/mydrafts - /api/blog/node/{store_type}/{store_id}/{id}/posts/mydrafts - argument - user - required - limited_support - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.json.ftl deleted file mode 100644 index 8c931b77a3..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mydrafts.get.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPostList /> diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.desc.xml deleted file mode 100644 index 34a4911d09..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Get blog posts (published) - Gets all published posts for a blog. - /api/blog/site/{site}/{container}/{path}/posts/mypublished - /api/blog/site/{site}/{container}/posts/mypublished - /api/blog/node/{store_type}/{store_id}/{id}/posts/mypublished - argument - user - required - limited_support - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.json.ftl deleted file mode 100644 index b955ab5451..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-mypublished.get.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPostList /> \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.desc.xml deleted file mode 100644 index e113d6cd6b..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Get blog posts for a number of days - Get all posts for a blog that were created within the specified number of days. - /api/blog/site/{site}/{container}/{path}/posts/new?numdays={numdays} - /api/blog/site/{site}/{container}/posts/new?numdays={numdays} - /api/blog/node/{store_type}/{store_id}/{id}/posts/new?numdays={numdays} - argument - user - required - limited_support - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.json.ftl deleted file mode 100644 index b955ab5451..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-new.get.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPostList /> \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-per-month.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-per-month.get.desc.xml deleted file mode 100644 index 78989e4b9f..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-per-month.get.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Get blog posts per month - Gets all months for which there are blog posts plus the number of posts in each. - /api/blog/site/{site}/{container}/{path}/postspermonth - /api/blog/site/{site}/{container}/postspermonth - /api/blog/node/{store_type}/{store_id}/{id}/postspermonth - argument - user - required - limited_support - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-per-month.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-per-month.get.json.ftl deleted file mode 100644 index decf31b8dd..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-per-month.get.json.ftl +++ /dev/null @@ -1,17 +0,0 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "items" : [ - <#list data as item> - { - "firstPostInMonth" : "${item.firstPostInMonth?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - "beginOfMonth" : "${item.beginOfMonth?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - "endOfMonth" : "${item.endOfMonth?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - "year" : ${item.year?c}, - "month" : ${item.month?c}, <#-- Note: January --> - "postCount" : ${item.count?c} - } - <#if item_has_next>, - - ] -} - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.desc.xml deleted file mode 100644 index 614d8f4818..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Get all externally published posts - Gets all externally published posts for a blog. - /api/blog/site/{site}/{container}/{path}/posts/publishedext - /api/blog/site/{site}/{container}/posts/publishedext - /api/blog/node/{store_type}/{store_id}/{id}/posts/publishedext - argument - user - required - limited_support - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.json.ftl deleted file mode 100644 index 8c931b77a3..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts-publishedext.get.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPostList /> diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.desc.xml deleted file mode 100644 index 66475883ae..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Get blog posts - Gets all posts for a blog. - /api/blog/site/{site}/{container}/{path}/posts - /api/blog/site/{site}/{container}/posts - /api/blog/node/{store_type}/{store_id}/{id}/posts - argument - user - required - limited_support - diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.json.ftl deleted file mode 100644 index b955ab5451..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.get.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPostList /> \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.desc.xml deleted file mode 100644 index f29672a29f..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.desc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - Create blog post - Creates a new blog post. - /api/blog/site/{site}/{container}/{path}/posts - /api/blog/site/{site}/{container}/posts - /api/blog/node/{store_type}/{store_id}/{id}/posts - argument - user - required - limited_support - \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.json.ftl deleted file mode 100644 index 709882b67f..0000000000 --- a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/blogs/posts/blog-posts.post.json.ftl +++ /dev/null @@ -1,2 +0,0 @@ -<#import "../blogpost.lib.ftl" as blogpostLib/> -<@blogpostLib.renderPost /> \ No newline at end of file diff --git a/src/main/resources/alfresco/web-scripts-application-context.xml b/src/main/resources/alfresco/web-scripts-application-context.xml index 151f7df1c6..d5b9286052 100644 --- a/src/main/resources/alfresco/web-scripts-application-context.xml +++ b/src/main/resources/alfresco/web-scripts-application-context.xml @@ -890,13 +890,6 @@ parent="baseArchivedNodeWebScript"> - - - - - - - diff --git a/src/test/java/org/alfresco/AppContext04TestSuite.java b/src/test/java/org/alfresco/AppContext04TestSuite.java index 0a7e749815..730a25440a 100644 --- a/src/test/java/org/alfresco/AppContext04TestSuite.java +++ b/src/test/java/org/alfresco/AppContext04TestSuite.java @@ -40,7 +40,6 @@ import org.junit.runners.Suite; org.alfresco.repo.web.scripts.quickshare.QuickShareRestApiTest.class, org.alfresco.repo.web.scripts.admin.AdminWebScriptTest.class, org.alfresco.repo.web.scripts.audit.AuditWebScriptTest.class, - org.alfresco.repo.web.scripts.blogs.BlogServiceTest.class, org.alfresco.repo.web.scripts.dictionary.DictionaryRestApiTest.class, org.alfresco.repo.web.scripts.activities.feed.control.FeedControlTest.class, org.alfresco.repo.web.scripts.forms.FormRestApiGet_Test.class, diff --git a/src/test/java/org/alfresco/repo/web/scripts/ReadOnlyTransactionInGetRestApiTest.java b/src/test/java/org/alfresco/repo/web/scripts/ReadOnlyTransactionInGetRestApiTest.java index 022edcd1e6..a0dde35074 100644 --- a/src/test/java/org/alfresco/repo/web/scripts/ReadOnlyTransactionInGetRestApiTest.java +++ b/src/test/java/org/alfresco/repo/web/scripts/ReadOnlyTransactionInGetRestApiTest.java @@ -57,7 +57,6 @@ public class ReadOnlyTransactionInGetRestApiTest extends BaseWebScriptTest { private static final String TEST_SITE_NAME = "readOnlyTestSite"; - private static final String URL_GET_SITE_BLOG = "/api/blog/site/" + TEST_SITE_NAME + "/blog"; private static final String URL_GET_SITE_LINKS = "/api/links/site/" + TEST_SITE_NAME + "/links?page=1&pageSize=10"; private static final String URL_GET_SITE_LINK = "/api/links/link/site/" + TEST_SITE_NAME + "/links/123456789"; private static final String URL_GET_SITE_TAGS = "/api/tagscopes/site/" + TEST_SITE_NAME + "/tags"; @@ -131,16 +130,6 @@ public class ReadOnlyTransactionInGetRestApiTest extends BaseWebScriptTest AuthenticationUtil.clearCurrentSecurityContext(); } - public void testGetSiteBlog() throws Exception - { - // TODO: Fixme - This REST API still requires a readwrite transaction to be successful - // Also add tests for all other blog GET REST APIs - - Response response = sendRequest(new GetRequest(URL_GET_SITE_BLOG), 200); - logResponse(response); - assertEquals(Status.STATUS_OK, response.getStatus()); - } - public void testGetSiteLinks() throws Exception { Response response = sendRequest(new GetRequest(URL_GET_SITE_LINKS), 200); diff --git a/src/test/java/org/alfresco/repo/web/scripts/WebScriptTestSuite.java b/src/test/java/org/alfresco/repo/web/scripts/WebScriptTestSuite.java index 509a5ecf4f..6b66424c8c 100644 --- a/src/test/java/org/alfresco/repo/web/scripts/WebScriptTestSuite.java +++ b/src/test/java/org/alfresco/repo/web/scripts/WebScriptTestSuite.java @@ -33,7 +33,6 @@ import org.alfresco.repo.web.scripts.action.RunningActionRestApiTest; import org.alfresco.repo.web.scripts.activities.feed.control.FeedControlTest; import org.alfresco.repo.web.scripts.admin.AdminWebScriptTest; import org.alfresco.repo.web.scripts.audit.AuditWebScriptTest; -import org.alfresco.repo.web.scripts.blogs.BlogServiceTest; import org.alfresco.repo.web.scripts.comment.CommentsApiTest; import org.alfresco.repo.web.scripts.custommodel.CustomModelImportTest; import org.alfresco.repo.web.scripts.dictionary.DictionaryRestApiTest; @@ -79,7 +78,6 @@ public class WebScriptTestSuite extends TestSuite suite.addTestSuite( QuickShareRestApiTest.class ); suite.addTestSuite( AdminWebScriptTest.class ); suite.addTestSuite( AuditWebScriptTest.class ); - suite.addTestSuite( BlogServiceTest.class ); suite.addTestSuite( DictionaryRestApiTest.class ); suite.addTestSuite( FeedControlTest.class ); suite.addTestSuite( FormRestApiGet_Test.class ); diff --git a/src/test/java/org/alfresco/repo/web/scripts/blogs/AllBlogTests.java b/src/test/java/org/alfresco/repo/web/scripts/blogs/AllBlogTests.java deleted file mode 100644 index a6d725a5ec..0000000000 --- a/src/test/java/org/alfresco/repo/web/scripts/blogs/AllBlogTests.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs; - -import org.alfresco.repo.blog.BlogServiceImplTest; -import org.alfresco.service.cmr.blog.BlogService; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * This class is a holder for the various test classes associated with the {@link BlogService}. - * It is not (at the time of writing) intended to be incorporated into the automatic build - * which will find the various test classes and run them individually. - * - * @author Neil Mc Erlean - * @since 4.0 - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - BlogServiceImplTest.class, - BlogServiceTest.class -}) -public class AllBlogTests -{ - // Intentionally empty -} diff --git a/src/test/java/org/alfresco/repo/web/scripts/blogs/BlogServiceTest.java b/src/test/java/org/alfresco/repo/web/scripts/blogs/BlogServiceTest.java deleted file mode 100644 index 0bbc1f0080..0000000000 --- a/src/test/java/org/alfresco/repo/web/scripts/blogs/BlogServiceTest.java +++ /dev/null @@ -1,998 +0,0 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ -package org.alfresco.repo.web.scripts.blogs; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.activities.feed.FeedGenerator; -import org.alfresco.repo.activities.post.lookup.PostLookup; -import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; -import org.alfresco.repo.node.archive.NodeArchiveService; -import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.site.SiteModel; -import org.alfresco.repo.web.scripts.BaseWebScriptTest; -import org.alfresco.service.cmr.activities.ActivityService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.cmr.site.SiteVisibility; -import org.alfresco.util.GUID; -import org.alfresco.util.PropertyMap; -import org.alfresco.util.testing.category.LuceneTests; -import org.alfresco.util.testing.category.RedundantTests; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONObject; -import org.json.JSONStringer; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.springframework.context.ApplicationContext; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest; -import org.springframework.extensions.webscripts.TestWebScriptServer.Response; - -/** - * Unit Test to test Blog Web Script API - * - * @author mruflin - */ -@Category(LuceneTests.class) -public class BlogServiceTest extends BaseWebScriptTest -{ - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(BlogServiceTest.class); - - private MutableAuthenticationService authenticationService; - private AuthenticationComponent authenticationComponent; - private PersonService personService; - private SiteService siteService; - private NodeArchiveService nodeArchiveService; - private ActivityService activityService; - private FeedGenerator feedGenerator; - private PostLookup postLookup; - - private static final String USER_ONE = "UserOneSecondToo"; - private static final String USER_TWO = "UserTwoSecondToo"; - private static final String SITE_SHORT_NAME_BLOG = "BlogSiteShortNameTest"; - private static final String COMPONENT_BLOG = "blog"; - - private static final String URL_BLOG_POST = "/api/blog/post/site/" + SITE_SHORT_NAME_BLOG + "/" + COMPONENT_BLOG + "/"; - private static final String URL_BLOG_CORE = "/api/blog/site/" + SITE_SHORT_NAME_BLOG + "/" + COMPONENT_BLOG; - private static final String URL_BLOG_POSTS = URL_BLOG_CORE + "/posts"; - private static final String URL_MY_DRAFT_BLOG_POSTS = "/api/blog/site/" + SITE_SHORT_NAME_BLOG + - "/" + COMPONENT_BLOG + "/posts/mydrafts"; - private static final String URL_MY_PUBLISHED_BLOG_POSTS = "/api/blog/site/" + SITE_SHORT_NAME_BLOG + - "/" + COMPONENT_BLOG + "/posts/mypublished"; - - private static final String URL_DELETE_COMMENT = "api/comment/node/{0}/{1}/{2}?site={3}&itemtitle={4}&page={5}"; - - private List posts; - private List drafts; - - - // General methods - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - this.authenticationService = (MutableAuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService"); - this.authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent"); - this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService"); - this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService"); - this.nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService"); - this.activityService = (ActivityService)getServer().getApplicationContext().getBean("activityService"); - ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)getServer().getApplicationContext().getBean("ActivitiesFeed"); - ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext(); - this.feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator"); - this.postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup"); - - // Authenticate as user - this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); - - // Create test site - // - only create the site if it doesn't already exist - SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_BLOG); - if (siteInfo == null) - { - this.siteService.createSite("BlogSitePreset", SITE_SHORT_NAME_BLOG, "BlogSiteTitle", "BlogSiteDescription", SiteVisibility.PUBLIC); - } - - // Create users - createUser(USER_ONE, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_BLOG); - createUser(USER_TWO, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_BLOG); - - // Blank our lists used to track things the test creates - posts = new ArrayList(5); - drafts = new ArrayList(5); - - // Do tests as inviter user - this.authenticationComponent.setCurrentUser(USER_ONE); - } - - @Override - protected void tearDown() throws Exception - { - super.tearDown(); - - // admin user required to delete things - this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); - - SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_BLOG); - if (siteInfo != null) - { - // delete invite site - siteService.deleteSite(SITE_SHORT_NAME_BLOG); - nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(siteInfo.getNodeRef())); - } - - - // delete the users - personService.deletePerson(USER_ONE); - if (this.authenticationService.authenticationExists(USER_ONE)) - { - this.authenticationService.deleteAuthentication(USER_ONE); - } - - personService.deletePerson(USER_TWO); - if (this.authenticationService.authenticationExists(USER_TWO)) - { - this.authenticationService.deleteAuthentication(USER_TWO); - } - } - - private void createUser(String userName, String role, String siteMembership) - { - // if user with given user name doesn't already exist then create user - if (this.authenticationService.authenticationExists(userName) == false) - { - // create user - this.authenticationService.createAuthentication(userName, "password".toCharArray()); - - // create person properties - PropertyMap personProps = new PropertyMap(); - personProps.put(ContentModel.PROP_USERNAME, userName); - personProps.put(ContentModel.PROP_FIRSTNAME, "FirstName123"); - personProps.put(ContentModel.PROP_LASTNAME, "LastName123"); - personProps.put(ContentModel.PROP_EMAIL, "FirstName123.LastName123@email.com"); - personProps.put(ContentModel.PROP_JOBTITLE, "JobTitle123"); - personProps.put(ContentModel.PROP_JOBTITLE, "Organisation123"); - - // create person node for user - this.personService.createPerson(personProps); - } - - // add the user as a member with the given role - this.siteService.setMembership(siteMembership, userName, role); - } - - - // Test helper methods - - private JSONObject getRequestObject(String title, String content, String[] tags, boolean isDraft) - throws Exception - { - JSONObject post = new JSONObject(); - if (title != null) - { - post.put("title", title); - } - if (content != null) - { - post.put("content", content); - } - if (tags != null) - { - JSONArray arr = new JSONArray(); - for (String s : tags) - { - arr.put(s); - } - post.put("tags", arr); - } - post.put("draft", isDraft); - return post; - } - - private JSONObject createPost(String title, String content, String[] tags, boolean isDraft, int expectedStatus) - throws Exception - { - JSONObject post = getRequestObject(title, content, tags, isDraft); - Response response = sendRequest(new PostRequest(URL_BLOG_POSTS, post.toString(), "application/json"), expectedStatus); - - if (expectedStatus != 200) - { - return null; - } - - //logger.debug(response.getContentAsString()); - JSONObject result = new JSONObject(response.getContentAsString()); - JSONObject item = result.getJSONObject("item"); - if (isDraft) - { - this.drafts.add(item.getString("name")); - } - else - { - this.posts.add(item.getString("name")); - } - return item; - } - - private JSONObject updatePost(String name, String title, String content, String[] tags, boolean isDraft, int expectedStatus) - throws Exception - { - JSONObject post = getRequestObject(title, content, tags, isDraft); - Response response = sendRequest(new PutRequest(URL_BLOG_POST + name, post.toString(), "application/json"), expectedStatus); - - if (expectedStatus != 200) - { - return null; - } - - JSONObject result = new JSONObject(response.getContentAsString()); - return result.getJSONObject("item"); - } - - private JSONObject getPost(String name, int expectedStatus) - throws Exception - { - Response response = sendRequest(new GetRequest(URL_BLOG_POST + name), expectedStatus); - if (expectedStatus == 200) - { - JSONObject result = new JSONObject(response.getContentAsString()); - return result.getJSONObject("item"); - } - else - { - return null; - } - } - - private String getCommentsUrl(String nodeRef) - { - return "/api/node/" + nodeRef.replace("://", "/") + "/comments"; - } - - private String getCommentUrl(String nodeRef) - { - return "/api/comment/node/" + nodeRef.replace("://", "/"); - } - - private String getDeleteCommentUrl(NodeRef commentNodeRef) - { - String itemTitle = "Test Title"; - String page = "document-details"; - - String URL = MessageFormat.format(URL_DELETE_COMMENT, new Object[] { commentNodeRef.getStoreRef().getProtocol(), - commentNodeRef.getStoreRef().getIdentifier(), commentNodeRef.getId(), SITE_SHORT_NAME_BLOG, itemTitle, page}); - return URL; - } - - private JSONObject createComment(String nodeRef, String title, String content, int expectedStatus) - throws Exception - { - JSONObject comment = new JSONObject(); - comment.put("title", title); - comment.put("content", content); - comment.put("site", SITE_SHORT_NAME_BLOG); - Response response = sendRequest(new PostRequest(getCommentsUrl(nodeRef), comment.toString(), "application/json"), expectedStatus); - - if (expectedStatus != 200) - { - return null; - } - - //logger.debug("Comment created: " + response.getContentAsString()); - JSONObject result = new JSONObject(response.getContentAsString()); - return result.getJSONObject("item"); - } - - private JSONObject updateComment(String nodeRef, String title, String content, int expectedStatus) - throws Exception - { - JSONObject comment = new JSONObject(); - comment.put("title", title); - comment.put("content", content); - Response response = sendRequest(new PutRequest(getCommentUrl(nodeRef), comment.toString(), "application/json"), expectedStatus); - - if (expectedStatus != 200) - { - return null; - } - - //logger.debug("Comment updated: " + response.getContentAsString()); - JSONObject result = new JSONObject(response.getContentAsString()); - return result.getJSONObject("item"); - } - - - // Tests - - public void testCreateDraftPost() throws Exception - { - String title = "test"; - String content = "test"; - JSONObject item = createPost(title, content, null, true, 200); - - // check that the values - assertEquals(title, item.get("title")); - assertEquals(content, item.get("content")); - assertEquals(true, item.get("isDraft")); - - // check that other user doesn't have access to the draft - this.authenticationComponent.setCurrentUser(USER_TWO); - getPost(item.getString("name"), 404); - this.authenticationComponent.setCurrentUser(USER_ONE); - - // Now we'll GET my-drafts to ensure that the post is there. - Response response = sendRequest(new GetRequest(URL_MY_DRAFT_BLOG_POSTS), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - assertTrue("Wrong number of posts", result.length() > 0); - } - - /** - * @since 4.0 - */ - @Test - @Category({LuceneTests.class, RedundantTests.class}) - public void testCreateDraftPostWithTagsAndComment() throws Exception - { - String[] tags = new String[]{"foo", "bar"}; - String title = "test"; - String content = "test"; - JSONObject item = createPost(title, content, tags, true, 200); - - // check that the values - assertEquals(title, item.get("title")); - assertEquals(content, item.get("content")); - assertEquals(true, item.get("isDraft")); - JSONArray reportedTags = (JSONArray)item.get("tags"); - assertEquals("Tags size was wrong.", 2, reportedTags.length()); - List recoveredTagsList = Arrays.asList(new String[]{reportedTags.getString(0), reportedTags.getString(1)}); - assertEquals("Tags were wrong.", Arrays.asList(tags), recoveredTagsList); - - // comment on the blog post. - NodeRef blogPostNode = new NodeRef(item.getString("nodeRef")); - // Currently (mid-Swift dev) there is no Java CommentService, so we have to post a comment via the REST API. - String commentsPostUrl = "/api/node/" + blogPostNode.getStoreRef().getProtocol() + - "/" + blogPostNode.getStoreRef().getIdentifier() + "/" + - blogPostNode.getId() + "/comments"; - - String jsonToPost = new JSONStringer().object() - .key("title").value("Commented blog title") - .key("content").value("Some content.") - .endObject().toString(); - - Response response = sendRequest(new PostRequest(commentsPostUrl, jsonToPost, "application/json"), 200); - - // check that other user doesn't have access to the draft - this.authenticationComponent.setCurrentUser(USER_TWO); - getPost(item.getString("name"), 404); - this.authenticationComponent.setCurrentUser(USER_ONE); - - // Now we'll GET my-drafts to ensure that the post is there. - response = sendRequest(new GetRequest(URL_MY_DRAFT_BLOG_POSTS), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - - // Ensure it reports the tag correctly on GET. - JSONArray items = result.getJSONArray("items"); - JSONArray tagsArray = items.getJSONObject(0).getJSONArray("tags"); - assertEquals("Wrong number of tags", 2, tagsArray.length()); - assertEquals("Tag wrong", tags[0], tagsArray.getString(0)); - assertEquals("Tag wrong", tags[1], tagsArray.getString(1)); - - // Ensure the comment count is accurate - assertEquals("Wrong comment count", 1, items.getJSONObject(0).getInt("commentCount")); - - // and that there is content at the commentsURL. - String commentsUrl = "/api" + items.getJSONObject(0).getString("commentsUrl"); - response = sendRequest(new GetRequest(commentsUrl), 200); - - - // Now get blog-post by tag. - // 1. No such tag - response = sendRequest(new GetRequest(URL_BLOG_POSTS + "?tag=NOSUCHTAG"), 200); - result = new JSONObject(response.getContentAsString()); - - assertEquals(0, result.getInt("total")); - - // tag created above - response = sendRequest(new GetRequest(URL_BLOG_POSTS + "?tag=foo"), 200); - result = new JSONObject(response.getContentAsString()); - - assertEquals(1, result.getInt("total")); - - //TODO More assertions on recovered node. - } - - public void testCreatePublishedPost() throws Exception - { - String title = "published"; - String content = "content"; - - JSONObject item = createPost(title, content, null, false, 200); - final String postName = item.getString("name"); - - // check the values - assertEquals(title, item.get("title")); - assertEquals(content, item.get("content")); - assertEquals(false, item.get("isDraft")); - - // check that user two has access to it as well - this.authenticationComponent.setCurrentUser(USER_TWO); - getPost(item.getString("name"), 200); - this.authenticationComponent.setCurrentUser(USER_ONE); - - // Now we'll GET my-published to ensure that the post is there. - Response response = sendRequest(new GetRequest(URL_MY_PUBLISHED_BLOG_POSTS), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - - // we should have posts.size + drafts.size together - assertEquals(this.posts.size() + this.drafts.size(), result.getInt("total")); - - // Finally, we'll delete the blog-post to test the REST DELETE call. - response = sendRequest(new DeleteRequest(URL_BLOG_POST + postName), 200); - - } - - public void testCreateEmptyPost() throws Exception - { - JSONObject item = createPost(null, null, null, false, 200); - - // check the values - assertEquals("", item.get("title")); - assertEquals("", item.get("content")); - assertEquals(false, item.get("isDraft")); - - // check that user two has access to it as well - this.authenticationComponent.setCurrentUser(USER_TWO); - getPost(item.getString("name"), 200); - this.authenticationComponent.setCurrentUser(USER_ONE); - } - - public void testUpdated() throws Exception - { - JSONObject item = createPost("test", "test", null, false, 200); - String name = item.getString("name"); - assertEquals(false, item.getBoolean("isUpdated")); - - item = updatePost(name, "new title", "new content", null, false, 200); - assertEquals(true, item.getBoolean("isUpdated")); - assertEquals("new title", item.getString("title")); - assertEquals("new content", item.getString("content")); - } - - public void testUpdateWithEmptyValues() throws Exception - { - JSONObject item = createPost("test", "test", null, false, 200); - String name = item.getString("name"); - assertEquals(false, item.getBoolean("isUpdated")); - - item = updatePost(item.getString("name"), null, null, null, false, 200); - assertEquals("", item.getString("title")); - assertEquals("", item.getString("content")); - } - - public void testPublishThroughUpdate() throws Exception - { - JSONObject item = createPost("test", "test", null, true, 200); - String name = item.getString("name"); - assertEquals(true, item.getBoolean("isDraft")); - - // check that user two does not have access - this.authenticationComponent.setCurrentUser(USER_TWO); - getPost(name, 404); - this.authenticationComponent.setCurrentUser(USER_ONE); - - item = updatePost(name, "new title", "new content", null, false, 200); - assertEquals("new title", item.getString("title")); - assertEquals("new content", item.getString("content")); - assertEquals(false, item.getBoolean("isDraft")); - - // check that user two does have access - this.authenticationComponent.setCurrentUser(USER_TWO); - getPost(name, 200); - this.authenticationComponent.setCurrentUser(USER_ONE); - } - - public void testCannotDoUnpublish() throws Exception - { - JSONObject item = createPost("test", "test", null, false, 200); - String name = item.getString("name"); - assertEquals(false, item.getBoolean("isDraft")); - - item = updatePost(name, "new title", "new content", null, true, 400); // should return bad request - } - - public void testGetAll() throws Exception - { - String url = URL_BLOG_POSTS; - Response response = sendRequest(new GetRequest(url), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - JSONObject blog; - - // We shouldn't have any posts at this point - assertEquals(0, this.posts.size()); - assertEquals(0, this.drafts.size()); - - assertEquals(0, result.getInt("total")); - assertEquals(0, result.getInt("startIndex")); - assertEquals(0, result.getInt("itemCount")); - assertEquals(0, result.getJSONArray("items").length()); - - // Check that the permissions are correct - JSONObject metadata = result.getJSONObject("metadata"); - JSONObject perms = metadata.getJSONObject("blogPermissions"); - assertEquals(false, metadata.getBoolean("externalBlogConfig")); - assertEquals(false, perms.getBoolean("delete")); // No container yet - assertEquals(true, perms.getBoolean("edit")); - assertEquals(true, perms.getBoolean("create")); - - - // Create a draft and a full post - String TITLE_1 = "Published"; - String TITLE_2 = "Draft"; - String TITLE_3 = "Another Published"; - createPost(TITLE_1, "Stuff", null, false, Status.STATUS_OK); - createPost(TITLE_2, "Draft Stuff", null, true, Status.STATUS_OK); - - // Check now - response = sendRequest(new GetRequest(url), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(2, result.getInt("total")); - assertEquals(0, result.getInt("startIndex")); - assertEquals(2, result.getInt("itemCount")); - assertEquals(2, result.getJSONArray("items").length()); - - // Check the core permissions - metadata = result.getJSONObject("metadata"); - perms = metadata.getJSONObject("blogPermissions"); - assertEquals(false, metadata.getBoolean("externalBlogConfig")); - assertEquals(true, perms.getBoolean("delete")); // On the container itself - assertEquals(true, perms.getBoolean("edit")); - assertEquals(true, perms.getBoolean("create")); - - // Check each one in detail, they'll come back Published - // then draft (newest first within that) - blog = result.getJSONArray("items").getJSONObject(0); - assertEquals(TITLE_1, blog.get("title")); - assertEquals(false, blog.getBoolean("isDraft")); - perms = blog.getJSONObject("permissions"); - assertEquals(true, perms.getBoolean("delete")); - assertEquals(true, perms.getBoolean("edit")); - - blog = result.getJSONArray("items").getJSONObject(1); - assertEquals(TITLE_2, blog.get("title")); - assertEquals(true, blog.getBoolean("isDraft")); - perms = blog.getJSONObject("permissions"); - assertEquals(true, perms.getBoolean("delete")); - assertEquals(true, perms.getBoolean("edit")); - - - // Add a third post - createPost(TITLE_3, "Still Stuff", null, false, Status.STATUS_OK); - - response = sendRequest(new GetRequest(url), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(3, result.getInt("total")); - assertEquals(0, result.getInt("startIndex")); - assertEquals(3, result.getInt("itemCount")); - assertEquals(3, result.getJSONArray("items").length()); - - // Published then draft, newest first - blog = result.getJSONArray("items").getJSONObject(0); - assertEquals(TITLE_3, blog.get("title")); - blog = result.getJSONArray("items").getJSONObject(1); - assertEquals(TITLE_1, blog.get("title")); - blog = result.getJSONArray("items").getJSONObject(2); - assertEquals(TITLE_2, blog.get("title")); - - - // Ensure that paging behaves properly - response = sendRequest(new GetRequest(url + "?pageSize=2&startIndex=0"), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(3, result.getInt("total")); - assertEquals(0, result.getInt("startIndex")); - assertEquals(2, result.getInt("itemCount")); - assertEquals(2, result.getJSONArray("items").length()); - - assertEquals(TITLE_3, result.getJSONArray("items").getJSONObject(0).get("title")); - assertEquals(TITLE_1, result.getJSONArray("items").getJSONObject(1).get("title")); - - - response = sendRequest(new GetRequest(url + "?pageSize=2&startIndex=1"), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(3, result.getInt("total")); - assertEquals(1, result.getInt("startIndex")); - assertEquals(2, result.getInt("itemCount")); - assertEquals(2, result.getJSONArray("items").length()); - - assertEquals(TITLE_1, result.getJSONArray("items").getJSONObject(0).get("title")); - assertEquals(TITLE_2, result.getJSONArray("items").getJSONObject(1).get("title")); - - - response = sendRequest(new GetRequest(url + "?pageSize=2&startIndex=2"), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(3, result.getInt("total")); - assertEquals(2, result.getInt("startIndex")); - assertEquals(1, result.getInt("itemCount")); - assertEquals(1, result.getJSONArray("items").length()); - - assertEquals(TITLE_2, result.getJSONArray("items").getJSONObject(0).get("title")); - - - // Switch user, check that permissions are correct - // (Drafts won't be seen) - this.authenticationComponent.setCurrentUser(USER_TWO); - - response = sendRequest(new GetRequest(url), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(2, result.getInt("total")); - assertEquals(0, result.getInt("startIndex")); - assertEquals(2, result.getInt("itemCount")); - - assertEquals(2, result.getJSONArray("items").length()); - blog = result.getJSONArray("items").getJSONObject(0); - assertEquals(TITLE_3, blog.get("title")); - assertEquals(false, blog.getBoolean("isDraft")); - perms = blog.getJSONObject("permissions"); - assertEquals(false, perms.getBoolean("delete")); - assertEquals(true, perms.getBoolean("edit")); - - blog = result.getJSONArray("items").getJSONObject(1); - assertEquals(TITLE_1, blog.get("title")); - assertEquals(false, blog.getBoolean("isDraft")); - perms = blog.getJSONObject("permissions"); - assertEquals(false, perms.getBoolean("delete")); - assertEquals(true, perms.getBoolean("edit")); - } - - public void testGetNew() throws Exception - { - String url = URL_BLOG_POSTS + "/new"; - Response response = sendRequest(new GetRequest(url), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - - // we should have posts.size - assertEquals(this.posts.size(), result.getInt("total")); - } - - public void testGetDrafts() throws Exception - { - String url = URL_BLOG_POSTS + "/mydrafts"; - Response response = sendRequest(new GetRequest(URL_BLOG_POSTS), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - - // we should have drafts.size resultss - assertEquals(this.drafts.size(), result.getInt("total")); - - // the second user should have zero - this.authenticationComponent.setCurrentUser(USER_TWO); - response = sendRequest(new GetRequest(url), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(0, result.getInt("total")); - this.authenticationComponent.setCurrentUser(USER_ONE); - - } - - public void testMyPublished() throws Exception - { - String url = URL_BLOG_POSTS + "/mypublished"; - Response response = sendRequest(new GetRequest(url), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - - // we should have posts.size results - assertEquals(this.drafts.size(), result.getInt("total")); - - // the second user should have zero - this.authenticationComponent.setCurrentUser(USER_TWO); - response = sendRequest(new GetRequest(url), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(0, result.getInt("total")); - this.authenticationComponent.setCurrentUser(USER_ONE); - } - - public void testComments() throws Exception - { - JSONObject item = createPost("test", "test", null, false, 200); - String name = item.getString("name"); - String nodeRef = item.getString("nodeRef"); - - JSONObject commentOne = createComment(nodeRef, "comment", "content", 200); - JSONObject commentTwo = createComment(nodeRef, "comment", "content", 200); - - // fetch the comments - Response response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - assertEquals(2, result.getInt("total")); - - // add another one - JSONObject commentThree = createComment(nodeRef, "comment", "content", 200); - - response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(3, result.getInt("total")); - - // delete the last comment - response = sendRequest(new DeleteRequest(getCommentUrl(commentThree.getString("nodeRef"))), 200); - - response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200); - result = new JSONObject(response.getContentAsString()); - assertEquals(2, result.getInt("total")); - - JSONObject commentTwoUpdated = updateComment(commentTwo.getString("nodeRef"), "new title", "new content", 200); - assertEquals("new title", commentTwoUpdated.getString("title")); - assertEquals("new content", commentTwoUpdated.getString("content")); - } - - /** - * REPO-828 (MNT-16401) - * @throws Exception - */ - public void testDeleteCommentPostActivity() throws Exception - { - this.authenticationComponent.setCurrentUser(USER_ONE); - JSONObject item = createPost("testActivity", "test", null, false, 200); - assertNotNull(item); - postLookup.execute(); - feedGenerator.execute(); - int activityNumStart = activityService.getSiteFeedEntries(SITE_SHORT_NAME_BLOG).size(); - String nodeRef = item.getString("nodeRef"); - JSONObject commentOne = createComment(nodeRef, "comment", "content", 200); - assertNotNull(item); - postLookup.execute(); - feedGenerator.execute(); - int activityNumNext = activityService.getSiteFeedEntries(SITE_SHORT_NAME_BLOG).size(); - assertEquals("The activity feeds were not generated after adding a comment", activityNumStart + 1, activityNumNext); - activityNumStart = activityNumNext; - NodeRef commentNodeRef = new NodeRef(commentOne.getString("nodeRef")); - Response resp = sendRequest(new DeleteRequest(getDeleteCommentUrl(commentNodeRef)), 200); - assertTrue(resp.getStatus() == 200); - postLookup.execute(); - feedGenerator.execute(); - activityNumNext = activityService.getSiteFeedEntries(SITE_SHORT_NAME_BLOG).size(); - assertEquals("The activity feeds were not generated after deleting a comment", activityNumStart + 1, activityNumNext); - } - - /** - * You can attach information to the blog container relating - * to integration with external blogs. - * This tests that feature - */ - public void testBlogIntegration() throws Exception - { - // Try to fetch the details on a new site - Response response = sendRequest(new GetRequest(URL_BLOG_CORE), 200); - String json = response.getContentAsString(); - JSONObject result = new JSONObject(json); - - assertEquals("No item in:\n"+json, true, result.has("item")); - JSONObject item = result.getJSONObject("item"); - - assertEquals("Missing key in: " + item, true, item.has("qnamePath")); - assertEquals("Missing key in: " + item, true, item.has("detailsUrl")); - assertEquals("Missing key in: " + item, true, item.has("blogPostsUrl")); - - // Blog properties are empty to start - assertEquals("", item.getString("type")); - assertEquals("", item.getString("name")); - assertEquals("", item.getString("description")); - assertEquals("", item.getString("url")); - assertEquals("", item.getString("username")); - assertEquals("", item.getString("password")); - - - // Have it updated - JSONObject blog = new JSONObject(); - blog.put("blogType", "wordpress"); - blog.put("blogName", "A Blog!"); - blog.put("username", "guest"); - sendRequest(new PutRequest(URL_BLOG_CORE, blog.toString(), "application/json"), Status.STATUS_OK); - - // Check again now - response = sendRequest(new GetRequest(URL_BLOG_CORE), 200); - json = response.getContentAsString(); - result = new JSONObject(json); - - assertEquals("No item in:\n"+json, true, result.has("item")); - item = result.getJSONObject("item"); - - assertEquals("Missing key in: " + item, true, item.has("qnamePath")); - assertEquals("Missing key in: " + item, true, item.has("detailsUrl")); - assertEquals("Missing key in: " + item, true, item.has("blogPostsUrl")); - - // Blog properties should now be set - assertEquals("wordpress", item.getString("type")); - assertEquals("A Blog!", item.getString("name")); - assertEquals("", item.getString("description")); - assertEquals("", item.getString("url")); - assertEquals("guest", item.getString("username")); - assertEquals("", item.getString("password")); - } - - /** - * Does some stress tests. - * - * Currently observed errors: - * 1. [repo.action.AsynchronousActionExecutionQueueImpl] Failed to execute asynchronous action: Action[ id=485211db-f117-4976-9530-ab861a19f563, node=null ] - * org.alfresco.repo.security.permissions.AccessDeniedException: Access Denied. You do not have the appropriate permissions to perform this operation. - * - * 2. JSONException, but with root cause being - * get(assocs) failed on instance of org.alfresco.repo.template.TemplateNode - * The problematic instruction: - * ---------- - * ==> if person.assocs["cm:avatar"]?? [on line 4, column 7 in org/alfresco/repository/blogs/blogpost.lib.ftl] - * - * @throws Exception - */ - public void _testTagsStressTest() throws Exception - { - final List exceptions = Collections.synchronizedList(new ArrayList()); - List threads = new ArrayList(); - - System.err.println("Creating and starting threads..."); - for (int x=0; x < 3; x++) - { - Thread t = new Thread(new Runnable() - { - public void run() - { - // set the correct user - authenticationComponent.setCurrentUser(USER_ONE); - - // now do some requests - try - { - for (int y=0; y < 3; y++) - { - off_testPostTags(); - off_testClearTags(); - } - System.err.println("------------- SUCCEEDED ---------------"); - } catch (Exception e) - { - System.err.println("------------- ERROR ---------------"); - exceptions.add(e); - e.printStackTrace(); - return; - } - }}); - - threads.add(t); - t.start(); - } - /*for (Thread t : threads) - { - t.start(); - }*/ - - for (Thread t : threads) - { - t.join(); - } - - System.err.println("------------- STACK TRACES ---------------"); - for (Exception e : exceptions) - { - e.printStackTrace(); - } - System.err.println("------------- STACK TRACES END ---------------"); - if (exceptions.size() > 0) - { - throw exceptions.get(0); - } - } - - public void off_testPostTags() throws Exception - { - String[] tags = { "first", "test" }; - JSONObject item = createPost("tagtest", "tagtest", tags, false, 200); - assertEquals(2, item.getJSONArray("tags").length()); - assertEquals("first", item.getJSONArray("tags").get(0)); - assertEquals("test", item.getJSONArray("tags").get(1)); - - item = updatePost(item.getString("name"), null, null, new String[] { "First", "Test", "Second" }, false, 200); - assertEquals(3, item.getJSONArray("tags").length()); - assertEquals("first", item.getJSONArray("tags").get(0)); - assertEquals("test", item.getJSONArray("tags").get(1)); - assertEquals("second", item.getJSONArray("tags").get(2)); - } - - public void off_testClearTags() throws Exception - { - String[] tags = { "abc", "def"}; - JSONObject item = createPost("tagtest", "tagtest", tags, false, 200); - assertEquals(2, item.getJSONArray("tags").length()); - - item = updatePost(item.getString("name"), null, null, new String[0], false, 200); - assertEquals(0, item.getJSONArray("tags").length()); - } - - /** - * Test for MNT-11964 - * @throws Exception - */ - public void testBlogPermission() throws Exception - { - this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); - - String siteName = SITE_SHORT_NAME_BLOG + GUID.generate(); - this.siteService.createSite("BlogSitePreset", siteName, "BlogSiteTitle", "BlogSiteDescription", SiteVisibility.PUBLIC); - - String userName = USER_ONE + GUID.generate(); - createUser(userName, SiteModel.SITE_COLLABORATOR, siteName); - - // Check permissions for admin - checkBlogPermissions(siteName); - - // Check permissions for user - this.authenticationComponent.setCurrentUser(userName); - checkBlogPermissions(siteName); - - // Cleanup - this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); - this.siteService.deleteSite(siteName); - - // Create a new site as user - this.authenticationComponent.setCurrentUser(userName); - siteName = SITE_SHORT_NAME_BLOG + GUID.generate(); - this.siteService.createSite("BlogSitePreset", siteName, "BlogSiteTitle", "BlogSiteDescription", SiteVisibility.PUBLIC); - - // Check permissions for user - checkBlogPermissions(siteName); - - // Check permissions for admin - this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); - checkBlogPermissions(siteName); - - // Cleanup - this.siteService.deleteSite(siteName); - this.personService.deletePerson(userName); - } - - private void checkBlogPermissions(String siteName) throws Exception - { - String url = "/api/blog/site/" + siteName + "/" + COMPONENT_BLOG; - Response response = sendRequest(new GetRequest(url), 200); - JSONObject result = new JSONObject(response.getContentAsString()); - - assertTrue("The user sould have permission to create a new blog.", result.getJSONObject("item").getJSONObject("permissions").getBoolean("create")); - } -} \ No newline at end of file diff --git a/src/test/java/org/alfresco/repo/web/scripts/calendar/CalendarRestApiTest.java b/src/test/java/org/alfresco/repo/web/scripts/calendar/CalendarRestApiTest.java index ec71468b2a..1c048226e0 100644 --- a/src/test/java/org/alfresco/repo/web/scripts/calendar/CalendarRestApiTest.java +++ b/src/test/java/org/alfresco/repo/web/scripts/calendar/CalendarRestApiTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * 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 . - * #L% - */ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * 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 . + * #L% + */ package org.alfresco.repo.web.scripts.calendar; import java.util.ArrayList; @@ -120,7 +120,7 @@ public class CalendarRestApiTest extends BaseWebScriptTest SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_CALENDAR); if (siteInfo == null) { - this.siteService.createSite("CalendarSitePreset", SITE_SHORT_NAME_CALENDAR, "CalendarSiteTitle", "BlogSiteDescription", SiteVisibility.PUBLIC); + this.siteService.createSite("CalendarSitePreset", SITE_SHORT_NAME_CALENDAR, "CalendarSiteTitle", "CalendarSiteDescription", SiteVisibility.PUBLIC); } // Ensure the calendar container is there diff --git a/src/test/java/org/alfresco/repo/web/scripts/comment/CommentsApiTest.java b/src/test/java/org/alfresco/repo/web/scripts/comment/CommentsApiTest.java index 31fcbdd8b5..254e0c0ae9 100644 --- a/src/test/java/org/alfresco/repo/web/scripts/comment/CommentsApiTest.java +++ b/src/test/java/org/alfresco/repo/web/scripts/comment/CommentsApiTest.java @@ -78,7 +78,7 @@ import org.springframework.extensions.webscripts.WebScriptException; /** * TODO: Fix the loose transaction handling. - * TODO: Rationalise with other v0 Comment REST API tests (eg. see BlogServiceTest ... etc). See also ACE-5437. + * TODO: Rationalise with other v0 Comment REST API tests. See also ACE-5437. */ public class CommentsApiTest extends BaseWebScriptTest {