From d076396436224f9c0e126090c1c12c376a3dec4f Mon Sep 17 00:00:00 2001 From: David Caruana Date: Sat, 1 Mar 2008 00:09:10 +0000 Subject: [PATCH] Web Scripts: Encapsulate concept of mimetype -> object -> mimetype conversions. Allows scripts, templates etc access to request mimetypes (e.g. Atom entry/feed, multipart/form-data) in a natural way (i.e. as objects). Such objects can then be serialized to the appropriate response mimetype (e.g. atom, json). New converters can be configured in. Refactored form post to this mechanism. Fixed script dump/load issue for scripts in root folder. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8412 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web-scripts-application-context.xml | 17 ++++++----------- .../alfresco/repo/web/scripts/RepoStore.java | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml index 22a4c9244e..d36b9b0690 100644 --- a/config/alfresco/web-scripts-application-context.xml +++ b/config/alfresco/web-scripts-application-context.xml @@ -103,26 +103,21 @@ - + Repository - - - - - - - - + + + + + - - diff --git a/source/java/org/alfresco/repo/web/scripts/RepoStore.java b/source/java/org/alfresco/repo/web/scripts/RepoStore.java index 0fc8818e62..16e85056e8 100644 --- a/source/java/org/alfresco/repo/web/scripts/RepoStore.java +++ b/source/java/org/alfresco/repo/web/scripts/RepoStore.java @@ -84,8 +84,7 @@ public class RepoStore implements Store, TenantDeployer protected FileFolderService fileService; protected NamespaceService namespaceService; protected PermissionService permissionService; - - private TenantDeployerService tenantDeployerService; + protected TenantDeployerService tenantDeployerService; /** @@ -310,11 +309,11 @@ public class RepoStore implements Store, TenantDeployer int baseDirLength = getBaseDir().length() +1; List documentPaths = new ArrayList(); String scriptPath = script.getDescription().getScriptPath(); - NodeRef scriptNodeRef = findNodeRef(scriptPath); + NodeRef scriptNodeRef = (scriptPath.length() == 0) ? getBaseNodeRef() : findNodeRef(scriptPath); if (scriptNodeRef != null) { org.alfresco.service.cmr.repository.Path repoScriptPath = nodeService.getPath(scriptNodeRef); - String id = script.getDescription().getId().substring(script.getDescription().getScriptPath().length() +1); + String id = script.getDescription().getId().substring(scriptPath.length() + (scriptPath.length() > 0 ? 1 : 0)); String query = "+PATH:\"" + repoScriptPath.toPrefixString(namespaceService) + "//*\" +QNAME:" + id + "*"; ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query); List nodes = resultSet.getNodeRefs(); @@ -436,7 +435,15 @@ public class RepoStore implements Store, TenantDeployer List folderElementsList = Arrays.asList(folderElements); // create folder - FileInfo pathInfo = fileService.makeFolders(getBaseNodeRef(), folderElementsList, ContentModel.TYPE_FOLDER); + FileInfo pathInfo; + if (folderElementsList.size() == 0) + { + pathInfo = fileService.getFileInfo(getBaseNodeRef()); + } + else + { + pathInfo = fileService.makeFolders(getBaseNodeRef(), folderElementsList, ContentModel.TYPE_FOLDER); + } // create file String fileName = pathElements[pathElements.length -1];