diff --git a/config/alfresco/templates/webscripts/org/alfresco/cmis/client/cmisbrowser/object.delete.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/cmis/client/cmisbrowser/object.delete.html.ftl index bc76bf4a45..44bbd5c86a 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/cmis/client/cmisbrowser/object.delete.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/cmis/client/cmisbrowser/object.delete.html.ftl @@ -31,8 +31,10 @@

${object.name?html} deleted!

+ <#if conn??>

Return to folder

+ - \ No newline at end of file + 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 new file mode 100644 index 0000000000..b8bde595f0 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/site/site-share-view-url.get.desc.xml @@ -0,0 +1,9 @@ + + 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 new file mode 100644 index 0000000000..2c504ff0b2 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/site/site-share-view-url.get.json.ftl @@ -0,0 +1,6 @@ +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "site": "${site.getShortName()}", + "url": "${url}" +} + diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnaildefinitions.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnaildefinitions.get.js index 960e4e72cb..74e171fb35 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnaildefinitions.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/thumbnail/thumbnaildefinitions.get.js @@ -13,11 +13,11 @@ function main() } // Get the thumbnail definitions - var thumbnailDefinitions = node.getThumbnailDefintions(); + var thumbnailDefinitions = node.getThumbnailDefinitions(); // Add them to the model model.node = node; model.thumbnailDefinitions = thumbnailDefinitions; } -main(); \ No newline at end of file +main(); diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.desc.xml deleted file mode 100644 index 8d0121c4c5..0000000000 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.desc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - roles - Document List Component - roles data webscript (Java-backed) - /slingshot/doclib/roles/{store_type}/{store_id}/{id} - argument - user - required - internal - \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.json.ftl deleted file mode 100644 index 57fa1e198b..0000000000 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/roles.get.json.ftl +++ /dev/null @@ -1,10 +0,0 @@ -<#escape x as jsonUtils.encodeJSONString(x)> -{ - "roles": - [ - <#list roles as role> - "${role}"<#if role_has_next>, - - ] -} - diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index 04c3ab0cae..56348bfa81 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -743,6 +743,13 @@ + + + + + + + diff --git a/source/java/org/alfresco/repo/web/scripts/datalist/DataListDownloadWebScript.java b/source/java/org/alfresco/repo/web/scripts/datalist/DataListDownloadWebScript.java index 99a72b9827..a53fcbade7 100644 --- a/source/java/org/alfresco/repo/web/scripts/datalist/DataListDownloadWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/datalist/DataListDownloadWebScript.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.StringTokenizer; import org.alfresco.model.ContentModel; +import org.alfresco.model.DataListModel; import org.alfresco.repo.web.scripts.DeclarativeSpreadsheetWebScript; import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.TypeDefinition; @@ -72,8 +73,7 @@ public class DataListDownloadWebScript extends DeclarativeSpreadsheetWebScript // Logger private static final Log logger = LogFactory.getLog(DataListDownloadWebScript.class); - private static final QName DATA_LIST_ITEM_TYPE = - QName.createQName(NamespaceService.DATALIST_MODEL_1_0_URI, "dataListItemType"); + private static final QName DATA_LIST_ITEM_TYPE = DataListModel.TYPE_DATALIST_ITEM; private NodeService nodeService; private SiteService siteService; diff --git a/source/java/org/alfresco/repo/web/scripts/site/SiteShareViewUrlGet.java b/source/java/org/alfresco/repo/web/scripts/site/SiteShareViewUrlGet.java new file mode 100644 index 0000000000..2826b45e6f --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/site/SiteShareViewUrlGet.java @@ -0,0 +1,271 @@ +/* + * 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 diff --git a/source/java/org/alfresco/repo/web/scripts/wiki/WikiPagePut.java b/source/java/org/alfresco/repo/web/scripts/wiki/WikiPagePut.java index fe942809bd..7b4f62fddb 100644 --- a/source/java/org/alfresco/repo/web/scripts/wiki/WikiPagePut.java +++ b/source/java/org/alfresco/repo/web/scripts/wiki/WikiPagePut.java @@ -129,7 +129,7 @@ public class WikiPagePut extends AbstractWikiWebScript { // Update the page page.setContents(contents); - if (tags != null && tags.size() > 0) + if (tags != null) { page.getTags().clear(); page.getTags().addAll(tags); diff --git a/source/java/org/alfresco/repo/webdav/MTNodesCache.java b/source/java/org/alfresco/repo/webdav/MTNodesCache.java deleted file mode 100644 index b71d740715..0000000000 --- a/source/java/org/alfresco/repo/webdav/MTNodesCache.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2005-2010 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.webdav; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.alfresco.repo.tenant.TenantService; -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.search.SearchService; -import org.alfresco.service.namespace.NamespaceService; - -/** - * In-memory cache that stores nodeRefs per tenant. - * It is initialized using path to node and allows to retrieve nodeRef for current tenant. - * - * @author Stas Sokolovsky - */ -public class MTNodesCache -{ - private NodeService nodeService; - - private SearchService searchService; - - private NamespaceService namespaceService; - - private TenantService tenantService; - - private Map nodesCache = new ConcurrentHashMap(); - - private String path = null; - - private NodeRef defaultNode = null; - - /** - * Constructor - * - * @param storeRef Store reference - * @param path Path to node - * @param nodeService NodeService - * @param searchService SearchService - * @param namespaceService NamespaceService - * @param tenantService TenantService - */ - public MTNodesCache(StoreRef storeRef, String path, NodeService nodeService, SearchService searchService, NamespaceService namespaceService, TenantService tenantService) - { - this.nodeService = nodeService; - this.searchService = searchService; - this.namespaceService = namespaceService; - this.tenantService = tenantService; - - if (nodeService.exists(storeRef) == false) - { - throw new RuntimeException("No store for path: " + storeRef); - } - - NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef); - - List nodeRefs = searchService.selectNodes(storeRootNodeRef, path, null, namespaceService, false); - - if (nodeRefs.size() > 1) - { - throw new RuntimeException("Multiple possible children for : \n" + " path: " + path + "\n" + " results: " + nodeRefs); - } - else if (nodeRefs.size() == 0) - { - throw new RuntimeException("Node is not found for : \n" + " root path: " + path); - } - - this.path = path; - defaultNode = nodeRefs.get(0); - - } - - /** - * Returns nodeRef for current user tenant - * - * @return nodeRef Node Reference - */ - public NodeRef getNodeForCurrentTenant() - { - NodeRef result = null; - - if (!tenantService.isEnabled()) - { - result = defaultNode; - } - else - { - String domain = tenantService.getCurrentUserDomain(); - if (nodesCache.containsKey(domain)) - { - result = nodesCache.get(domain); - } - else - { - result = tenantService.getRootNode(nodeService, searchService, namespaceService, path, defaultNode); - nodesCache.put(domain, result); - } - } - return result; - } - -} diff --git a/source/java/org/alfresco/repo/webdav/WebDAVServlet.java b/source/java/org/alfresco/repo/webdav/WebDAVServlet.java index ae6a89011a..91616704dd 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAVServlet.java +++ b/source/java/org/alfresco/repo/webdav/WebDAVServlet.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2011 Alfresco Software Limited. * * This file is part of Alfresco * @@ -22,6 +22,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Hashtable; +import java.util.List; import javax.servlet.ServletConfig; import javax.servlet.ServletException; @@ -31,6 +32,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.transaction.UserTransaction; +import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.security.authentication.AuthenticationContext; import org.alfresco.repo.tenant.TenantService; import org.alfresco.service.ServiceRegistry; @@ -66,27 +68,35 @@ public class WebDAVServlet extends HttpServlet // Constants public static final String WEBDAV_PREFIX = "webdav"; - private static final String INTERNAL_SERVER_ERROR = "Internal Server Error: "; - + //private static final String INTERNAL_SERVER_ERROR = "Internal Server Error: "; + // Init parameter names private static final String BEAN_INIT_PARAMS = "webdav.initParams"; // Service registry, used by methods to find services to process requests - private ServiceRegistry m_serviceRegistry; + private ServiceRegistry serviceRegistry; + + private TransactionService transactionService; + private static TenantService tenantService; + private static NodeService nodeService; + private static SearchService searchService; + private static NamespaceService namespaceService; - // Transaction service, each request is wrapped in a transaction - private TransactionService m_transactionService; - // WebDAV method handlers protected Hashtable> m_davMethods; - // Root node - private static MTNodesCache m_rootNodes; + // note: cache is tenant-aware (if using EhCacheAdapter shared cache) + + private static SimpleCache singletonCache; // eg. for webdavRootNodeRef + private static final String KEY_WEBDAV_ROOT_NODEREF = "key.webdavRoot.noderef"; + + private static String rootPath; + + private static NodeRef defaultRootNode; // for default domain // WebDAV helper class private WebDAVHelper m_davHelper; private ActivityPoster activityPoster; - private TenantService tenantService; /** * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, @@ -101,8 +111,8 @@ public class WebDAVServlet extends HttpServlet startTime = System.currentTimeMillis(); } - FileFilterMode.setClient(Client.webdav); - + FileFilterMode.setClient(Client.webdav); + try { // Create the appropriate WebDAV method for the request and execute it @@ -191,7 +201,7 @@ public class WebDAVServlet extends HttpServlet { logger.info(request.getMethod() + " took " + (System.currentTimeMillis()-startTime) + "ms to execute ["+request.getRequestURI()+"]"); } - + FileFilterMode.clearClient(); } } @@ -222,8 +232,7 @@ public class WebDAVServlet extends HttpServlet { // Create the handler method method = methodClass.newInstance(); - NodeRef rootNodeRef = m_rootNodes.getNodeForCurrentTenant(); - method.setDetails(request, response, m_davHelper, rootNodeRef); + method.setDetails(request, response, m_davHelper, getRootNodeRef()); // A very few WebDAV methods produce activity posts. if (method instanceof ActivityPostProducer) @@ -245,6 +254,19 @@ public class WebDAVServlet extends HttpServlet return method; } + + private static NodeRef getRootNodeRef() + { + NodeRef rootNodeRef = singletonCache.get(KEY_WEBDAV_ROOT_NODEREF); + + if (rootNodeRef == null) + { + rootNodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, rootPath, defaultRootNode); + singletonCache.put(KEY_WEBDAV_ROOT_NODEREF, rootNodeRef); + } + + return rootNodeRef; + } /** * Initialize the servlet @@ -252,6 +274,7 @@ public class WebDAVServlet extends HttpServlet * @param config ServletConfig * @exception ServletException */ + @SuppressWarnings("unchecked") public void init(ServletConfig config) throws ServletException { super.init(config); @@ -268,7 +291,7 @@ public class WebDAVServlet extends HttpServlet // Get global configuration properties WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); WebDAVInitParameters initParams = (WebDAVInitParameters) wc.getBean(BEAN_INIT_PARAMS); - + // Render this servlet permanently unavailable if its enablement property is not set if (!initParams.getEnabled()) { @@ -278,30 +301,33 @@ public class WebDAVServlet extends HttpServlet // Get root paths String storeValue = initParams.getStoreName(); - String rootPath = initParams.getRootPath(); - + + rootPath = initParams.getRootPath(); + // Get beans - m_serviceRegistry = (ServiceRegistry)context.getBean(ServiceRegistry.SERVICE_REGISTRY); + serviceRegistry = (ServiceRegistry)context.getBean(ServiceRegistry.SERVICE_REGISTRY); - m_transactionService = m_serviceRegistry.getTransactionService(); + transactionService = serviceRegistry.getTransactionService(); tenantService = (TenantService) context.getBean("tenantService"); + AuthenticationService authService = (AuthenticationService) context.getBean("authenticationService"); + NodeService nodeService = (NodeService) context.getBean("NodeService"); SearchService searchService = (SearchService) context.getBean("SearchService"); NamespaceService namespaceService = (NamespaceService) context.getBean("NamespaceService"); ActivityService activityService = (ActivityService) context.getBean("activityService"); - PersonService personService = m_serviceRegistry.getPersonService(); + PersonService personService = serviceRegistry.getPersonService(); + singletonCache = (SimpleCache)context.getBean("immutableSingletonCache"); // Collaborator used by WebDAV methods to create activity posts. activityPoster = new ActivityPosterImpl(activityService, nodeService, personService); - + // Create the WebDAV helper - m_davHelper = new WebDAVHelper(m_serviceRegistry, authService, tenantService); + m_davHelper = new WebDAVHelper(serviceRegistry, authService, tenantService); // Initialize the root node - - initializeRootNode(storeValue, rootPath, context, nodeService, searchService, namespaceService, tenantService, m_transactionService); + initializeRootNode(storeValue, rootPath, context, nodeService, searchService, namespaceService, tenantService, transactionService); // Create the WebDAV methods table @@ -352,11 +378,30 @@ public class WebDAVServlet extends HttpServlet if (tx != null) tx.begin(); - - m_rootNodes = new MTNodesCache(new StoreRef(storeValue), rootPath, nodeService, searchService, namespaceService, tenantService); - + + StoreRef storeRef = new StoreRef(storeValue); + + if (nodeService.exists(storeRef) == false) + { + throw new RuntimeException("No store for path: " + storeRef); + } + + NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef); + + List nodeRefs = searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false); + + if (nodeRefs.size() > 1) + { + throw new RuntimeException("Multiple possible children for : \n" + " path: " + rootPath + "\n" + " results: " + nodeRefs); + } + else if (nodeRefs.size() == 0) + { + throw new RuntimeException("Node is not found for : \n" + " root path: " + rootPath); + } + + defaultRootNode = nodeRefs.get(0); + // Commit the transaction - if (tx != null) tx.commit(); } @@ -378,7 +423,7 @@ public class WebDAVServlet extends HttpServlet */ public static NodeRef getWebdavRootNode() { - return m_rootNodes.getNodeForCurrentTenant(); + return getRootNodeRef(); } /**