${project.build.directory}/alf_dataconvert
- 7.55
+ 7.567.98.291.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