From f55c3091ea0e6ae0531697c37304edb9062fa97a Mon Sep 17 00:00:00 2001 From: Jon Cox Date: Mon, 25 Dec 2006 02:07:46 +0000 Subject: [PATCH] Fixed up paths a bit more so that now you get files paths like this: mysite--guest--preview/HEAD/DATA/www/avm_webapps/ROOT/WEB-INF/... and: mysite--guest--preview/VERSION/v1/DATA/www/avm_webapps/ROOT/WEB-INF/... rather than: mysite--guest--preview/HEAD/DATA/appBase/avm_webapps/ROOT/WEB-INF/... and: mysite--guest--preview/VERSION/v1/DATA/appBase/avm_webapps/ROOT/WEB-INF/... The reason for this is that the actual "appliation base" is and always has been "avm_webapps"; the original reason for making the *parent* of this dir called appBase had do do with the fact that you can have diffrent app bases for different virtual hosts. However, in the end it causes way more confusion than it was ever worth, so it's gone now. The reason for all the modified files is that people were hard-coding values in many different places, and/or defining their own constants for something that was needed at a higher level. As a temporary measure (I hope), I've defined some rather ugly-looking constants in JNDIConstants.java, and have used them everywhere: DIR_DEFAULT_WWW = "www" DIR_DEFAULT_APPBASE = "avm_webapps" The reason for calling the parent of the new application base "www" is that will be the default place that www-centric stuff happens (therefore, it's also the level at which the overlays take place). Ultimately, I'd like to turn these into spring configs, and bring back support for multiple AVMHost nodes within the same Tomcat... but it's not a priority at the moment. Please don't hard-code any dirs named "appBase" as the root level dir in a repo -- it's now "www", and will change again to a function call later when/if virtual AVMHosts come back. Keeping them as constants also helps them to be easier to find when overhauling things. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4696 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/repo/avm/AVMServiceTest.java | 46 ++++++++++--------- .../avm/actions/SimpleAVMPromoteAction.java | 7 +-- .../java/org/alfresco/repo/jscript/AVM.java | 10 ++-- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTest.java b/source/java/org/alfresco/repo/avm/AVMServiceTest.java index b6ec58d256..398bd20d70 100644 --- a/source/java/org/alfresco/repo/avm/AVMServiceTest.java +++ b/source/java/org/alfresco/repo/avm/AVMServiceTest.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import org.alfresco.config.JNDIConstants; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMModel; import org.alfresco.repo.action.ActionImpl; @@ -391,14 +392,14 @@ public class AVMServiceTest extends AVMServiceTestBase try { setupBasicTree(); - fService.createDirectory("main:/", "appBase"); - fService.rename("main:/", "a", "main:/appBase", "a"); - fService.rename("main:/", "d", "main:/appBase", "d"); + fService.createDirectory("main:/", JNDIConstants.DIR_DEFAULT_WWW ); + fService.rename("main:/", "a", "main:/" + JNDIConstants.DIR_DEFAULT_WWW, "a"); + fService.rename("main:/", "d", "main:/" + JNDIConstants.DIR_DEFAULT_WWW, "d"); fService.createSnapshot("main", null, null); fService.createStore("source"); - fService.createLayeredDirectory("main:/appBase", "source:/", "appBase"); - fService.getFileOutputStream("source:/appBase/a/b/c/foo").close(); - final ActionImpl action = new ActionImpl(AVMNodeConverter.ToNodeRef(-1, "source:/appBase/a"), + fService.createLayeredDirectory("main:/" + JNDIConstants.DIR_DEFAULT_WWW , "source:/", JNDIConstants.DIR_DEFAULT_WWW ); + fService.getFileOutputStream("source:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c/foo").close(); + final ActionImpl action = new ActionImpl(AVMNodeConverter.ToNodeRef(-1, "source:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a"), GUID.generate(), SimpleAVMPromoteAction.NAME); action.setParameterValue(SimpleAVMPromoteAction.PARAM_TARGET_STORE, "main"); @@ -407,13 +408,14 @@ public class AVMServiceTest extends AVMServiceTestBase { public Object doWork() throws Exception { - promote.execute(action, AVMNodeConverter.ToNodeRef(-1, "source:/appBase/a")); + promote.execute(action, AVMNodeConverter.ToNodeRef(-1, "source:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a")); return null; } }; TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"), new TxnWork()); - assertEquals(0, fSyncService.compare(-1, "source:/appBase", -1, "main:/appBase", null).size()); + assertEquals(0, fSyncService.compare(-1, "source:/" + JNDIConstants.DIR_DEFAULT_WWW , + -1, "main:/" + JNDIConstants.DIR_DEFAULT_WWW, null).size()); } catch (Exception e) { @@ -458,28 +460,28 @@ public class AVMServiceTest extends AVMServiceTestBase try { fService.createStore("foo-staging"); - fService.createDirectory("foo-staging:/", "appBase"); - fService.createDirectory("foo-staging:/appBase", "a"); - fService.createDirectory("foo-staging:/appBase/a","b"); - fService.createDirectory("foo-staging:/appBase/a/b", "c"); - fService.createFile("foo-staging:/appBase/a/b/c", "foo").close(); - fService.createFile("foo-staging:/appBase/a/b/c", "bar").close(); + fService.createDirectory("foo-staging:/", JNDIConstants.DIR_DEFAULT_WWW ); + fService.createDirectory("foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW, "a"); + fService.createDirectory("foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a","b"); + fService.createDirectory("foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b", "c"); + fService.createFile("foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c", "foo").close(); + fService.createFile("foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c", "bar").close(); fService.createStore("area"); fService.setStoreProperty("area", QName.createQName(null, ".website.name"), new PropertyValue(null, "foo")); - fService.createLayeredDirectory("foo-staging:/appBase", "area:/", "appBase"); - fService.createFile("area:/appBase", "figs").close(); - fService.getFileOutputStream("area:/appBase/a/b/c/foo").close(); - fService.removeNode("area:/appBase/a/b/c/bar"); + fService.createLayeredDirectory("foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW , "area:/", JNDIConstants.DIR_DEFAULT_WWW ); + fService.createFile("area:/" + JNDIConstants.DIR_DEFAULT_WWW, "figs").close(); + fService.getFileOutputStream("area:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c/foo").close(); + fService.removeNode("area:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c/bar"); List diffs = - fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase", null); + fSyncService.compare(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW, -1, "foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW, null); assertEquals(3, diffs.size()); final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction)fContext.getBean("simple-avm-submit"); class TxnWork implements TransactionUtil.TransactionWork { public Object doWork() throws Exception { - action.execute(null, AVMNodeConverter.ToNodeRef(-1, "area:/appBase")); + action.execute(null, AVMNodeConverter.ToNodeRef(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW )); return null; } }; @@ -487,7 +489,9 @@ public class AVMServiceTest extends AVMServiceTestBase TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"), worker); diffs = - fSyncService.compare(-1, "area:/appBase", -1, "foo-staging:/appBase", null); + fSyncService.compare(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW, + -1, "foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW, null); + assertEquals(0, diffs.size()); } catch (Exception e) diff --git a/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java b/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java index 2399ccfb8c..9d0b94f2d5 100644 --- a/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java +++ b/source/java/org/alfresco/repo/avm/actions/SimpleAVMPromoteAction.java @@ -19,8 +19,9 @@ package org.alfresco.repo.avm.actions; import java.util.List; -import org.alfresco.repo.action.ParameterDefinitionImpl; +import org.alfresco.config.JNDIConstants; import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; +import org.alfresco.repo.action.ParameterDefinitionImpl; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ParameterDefinition; @@ -94,8 +95,8 @@ public class SimpleAVMPromoteAction extends ActionExecuterAbstractBase // Do the promote. fAVMSyncService.update(diffs, null, true, true, false, false, null, null); // Flatten the source on top of the destination. - fAVMSyncService.flatten(storePath[0] + ":/appBase", - targetStoreName + ":/appBase"); + fAVMSyncService.flatten(storePath[0] + ":/" + JNDIConstants.DIR_DEFAULT_WWW, + targetStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW); } /** diff --git a/source/java/org/alfresco/repo/jscript/AVM.java b/source/java/org/alfresco/repo/jscript/AVM.java index 2b204c03fc..bdf9bd6343 100644 --- a/source/java/org/alfresco/repo/jscript/AVM.java +++ b/source/java/org/alfresco/repo/jscript/AVM.java @@ -16,9 +16,10 @@ */ package org.alfresco.repo.jscript; +import org.alfresco.config.JNDIConstants; import org.alfresco.repo.avm.AVMNodeConverter; -import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; +import org.alfresco.service.ServiceRegistry; import org.mozilla.javascript.Scriptable; /** @@ -97,15 +98,12 @@ public final class AVM extends BaseScriptImplementation implements Scopeable public static String getWebappsFolderPath() { - return '/' + DIR_APPBASE + '/' + DIR_WEBAPPS; + return '/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + + JNDIConstants.DIR_DEFAULT_APPBASE; } public static String jsGet_webappsFolderPath() { return getWebappsFolderPath(); } - - // system directories at the top level of an AVM website - private final static String DIR_APPBASE = "appBase"; - private final static String DIR_WEBAPPS = "avm_webapps"; }