diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/site/site-share-view-url.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/site/site-share-view-url.get.desc.xml deleted file mode 100644 index b8bde595f0..0000000000 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/site/site-share-view-url.get.desc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - Get the Share URL to View a Site Node - Gets the appropriate Share URL to view a given Site Node within Share - /api/sites/shareUrl - argument - user - required - internal - diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/site/site-share-view-url.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/site/site-share-view-url.get.json.ftl deleted file mode 100644 index 2c504ff0b2..0000000000 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/site/site-share-view-url.get.json.ftl +++ /dev/null @@ -1,6 +0,0 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "site": "${site.getShortName()}", - "url": "${url}" -} - diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index bc6ed2e1ca..e99291e060 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -568,12 +568,6 @@ - - - - - - diff --git a/source/java/org/alfresco/repo/web/scripts/site/SiteShareViewUrlGet.java b/source/java/org/alfresco/repo/web/scripts/site/SiteShareViewUrlGet.java deleted file mode 100644 index 2826b45e6f..0000000000 --- a/source/java/org/alfresco/repo/web/scripts/site/SiteShareViewUrlGet.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (C) 2005-2011 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.web.scripts.site; - -import java.text.SimpleDateFormat; -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.model.DataListModel; -import org.alfresco.model.ForumModel; -import org.alfresco.repo.admin.SysAdminParams; -import org.alfresco.repo.calendar.CalendarModel; -import org.alfresco.repo.site.SiteModel; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.site.SiteInfo; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.UrlUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -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; - -/** - * Returns the Share URL to view a given NodeRef. - * - * The supplied NodeRef must be within a Site, and must be - * of a type supported by Share - * - * @author Nick Burch - * @since 4.0.2 - */ -public class SiteShareViewUrlGet extends DeclarativeWebScript -{ - private static Log logger = LogFactory.getLog(SiteShareViewUrlGet.class); - - protected NodeService nodeService; - protected SiteService siteService; - protected SysAdminParams sysAdminParams; - protected DictionaryService dictionaryService; - - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { - // Grab the NodeRef - String nodeRefS = req.getParameter("nodeRef"); - if (nodeRefS == null) - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "NodeRef must be supplied"); - if (! NodeRef.isNodeRef(nodeRefS)) - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid NodeRef"); - - // Check the node exists - NodeRef nodeRef = new NodeRef(nodeRefS); - if (! nodeService.exists(nodeRef)) - throw new WebScriptException(Status.STATUS_NOT_FOUND, "Node Does Not Exist"); - - - // Work out what site it's in, and what container in the site - SiteInfo site = null; - NodeRef siteContainer = null; - { - NodeRef current = nodeRef; - NodeRef prev = null; - while (current != null) - { - // Are we at a site yet? - QName type = nodeService.getType(current); - if (dictionaryService.isSubClass(type, SiteModel.TYPE_SITE)) - { - // Found it! - siteContainer = prev; - site = siteService.getSite(current); - break; - } - - // Step down - prev = current; - current = nodeService.getPrimaryParent(current).getParentRef(); - } - } - if (site == null) - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Node isn't part of a site"); - - // Grab the main URL for the site - String baseUrl = getShareSiteRootStem(req, site); - - // Identify the appropriate Share URL, based on the Node Type - QName nodeType = nodeService.getType(nodeRef); - - - // Start on the model - Map model = new HashMap(); - model.put("node", nodeRef); - model.put("site", site); - model.put("type", nodeType); - - // Get the URL, and we're done - String page = identifySharePage(nodeRef, site, siteContainer, nodeType); - model.put("url", baseUrl + page); - - return model; - } - - private static QName TYPE_LINK = QName.createQName(NamespaceService.LINKS_MODEL_1_0_URI, "link"); - protected String identifySharePage(NodeRef nodeRef, SiteInfo site, NodeRef siteContainer, QName nodeType) - { - // Grab the name of the Node itself - often used for the URL - String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); - - - // Wiki and Blog both use cm:content in special containers - if (siteContainer != null && dictionaryService.isSubClass(nodeType, ContentModel.TYPE_CONTENT)) - { - QName containerName = nodeService.getPrimaryParent(siteContainer).getQName(); - if (containerName.equals( QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "blog") )) - { - // Wiki - cm:content in folder called cm:wiki - return "wiki-page?title=" + name; - } - if (containerName.equals( QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "wiki") )) - { - // Blog - cm:content in cm:blog - return "blog-postview?postId=" + name; - } - } - - // Is it a Data List? - if (dictionaryService.isSubClass(nodeType, DataListModel.TYPE_DATALIST)) - { - return "data-lists?list=" + name; - } - - // Is it a Link? - if (dictionaryService.isSubClass(nodeType, TYPE_LINK)) - { - return "links-view?linkId=" + name; - } - - // Is it a Calendar Entry? - if (dictionaryService.isSubClass(nodeType, CalendarModel.TYPE_EVENT)) - { - // Find the date - Date date = (Date)nodeService.getProperty(nodeRef, CalendarModel.PROP_FROM_DATE); - SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); - - // Build the URL based on it - return "calendar?date=" + fmt.format(date); - } - - // Is it a discussions topic or post? - if (dictionaryService.isSubClass(nodeType, ForumModel.TYPE_TOPIC)) - { - // Topic is easy - return "discussions-topicview?topicId=" + name; - } - if (dictionaryService.isSubClass(nodeType, ForumModel.TYPE_POST)) - { - // Go from post to the topic, then list from there - NodeRef postTopic = nodeService.getPrimaryParent(nodeRef).getParentRef(); - String topicName = (String)nodeService.getProperty(postTopic, ContentModel.PROP_NAME); - return "discussions-topicview?topicId=" + topicName; - } - - // Is it just regular content? - if (dictionaryService.isSubClass(nodeType, ContentModel.TYPE_CONTENT)) - { - // Simple, Document Details with a noderef - return "document-details?nodeRef=" + nodeRef.toString(); - } - - // Is it a normal folder? - if (dictionaryService.isSubClass(nodeType, ContentModel.TYPE_FOLDER)) - { - // Need the path within the site - List paths = new ArrayList(); - NodeRef current = nodeRef; - while (current != null && !current.equals(siteContainer) && !current.equals(site.getNodeRef())) - { - paths.add( (String)nodeService.getProperty(current, ContentModel.PROP_NAME) ); - current = nodeService.getPrimaryParent(current).getParentRef(); - } - - // Invert to build the path - StringBuilder path = new StringBuilder(); - for (int i=paths.size()-1; i>=0; i--) - { - path.append('/'); - path.append(paths.get(i)); - } - - if (path.length() > 0) - { - // Becomes documentlibrary?path=/Docs/Beta - return "documentlibrary?path=" + path.toString(); - } - else - { - // Just the root of the document library - return "documentlibrary"; - } - } - - // If we can't work out what it is, log and take them to the site dashboard - if (logger.isDebugEnabled()) - logger.debug("COuldn't identify specific URL for Node " + nodeRef + " of type " + nodeType); - return "dashboard"; - } - - /** - * Returns the root of the Share Site pages for a given site, eg - * https://test.alfresco.com/share/page/site/test-site/ - */ - protected String getShareSiteRootStem(WebScriptRequest req, SiteInfo site) - { - return getShareRootUrl(req) + "page/site/" + site.getShortName() + "/"; - } - /** - * Returns the root of the Share WebApp, eg - * http://localhost:8081/share/ - */ - protected String getShareRootUrl(WebScriptRequest req) - { - return UrlUtil.getShareUrl(sysAdminParams) + "/"; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setSiteService(SiteService siteService) - { - this.siteService = siteService; - } - - public void setSysAdminParams(SysAdminParams sysAdminParams) - { - this.sysAdminParams = sysAdminParams; - } - - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } -} \ No newline at end of file