From d4d33c1e34ac0378f65c0c2b97a178b94e865a14 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Wed, 22 Mar 2006 16:21:14 +0000 Subject: [PATCH] Merge V1.2.0 BRANCH to HEAD svn merge -r 2566:2569 svn://www.alfresco.org/alfresco/BRANCHES/V1.2.0/root HEAD/root git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2570 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/patch/patch-services-context.xml | 4 + config/alfresco/version.properties | 2 +- .../descriptor/DescriptorServiceImpl.java | 87 ++++++++++++------- .../repo/importer/ImporterBootstrap.java | 17 ++++ .../service/descriptor/DescriptorService.java | 4 +- 5 files changed, 82 insertions(+), 32 deletions(-) diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index fd3260af02..6758481f2c 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -359,4 +359,8 @@ + + + +>>>>>>> .merge-right.r2569 diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties index 967997f2b9..6c47efc00b 100644 --- a/config/alfresco/version.properties +++ b/config/alfresco/version.properties @@ -15,4 +15,4 @@ version.edition=Community Network # Schema number -version.schema=10 +version.schema=11 diff --git a/source/java/org/alfresco/repo/descriptor/DescriptorServiceImpl.java b/source/java/org/alfresco/repo/descriptor/DescriptorServiceImpl.java index 7e05f84dea..91dd547322 100644 --- a/source/java/org/alfresco/repo/descriptor/DescriptorServiceImpl.java +++ b/source/java/org/alfresco/repo/descriptor/DescriptorServiceImpl.java @@ -160,7 +160,7 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList */ public LicenseDescriptor getLicenseDescriptor() { - return licenseService.getLicense(); + return (licenseService == null) ? null : licenseService.getLicense(); } /** @@ -176,6 +176,9 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList { public Descriptor doWork() { + // initialise license service (if installed) + initialiseLicenseService(); + // verify license, but only if license component is installed licenseService.verifyLicense(); @@ -197,9 +200,6 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList { // initialise server descriptor serverDescriptor = createServerDescriptor(); - - // initialise license service (if installed) - initialiseLicenseService(); } /** @@ -239,6 +239,33 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList } } + /** + * Create current repository descriptor + * + * @return descriptor + */ + private Descriptor createCurrentRepositoryDescriptor() + { + // retrieve system descriptor location + StoreRef storeRef = systemBootstrap.getStoreRef(); + Properties systemProperties = systemBootstrap.getConfiguration(); + String path = systemProperties.getProperty("system.descriptor.current.childname"); + + // retrieve system descriptor + NodeRef descriptorNodeRef = getDescriptorNodeRef(storeRef, path, false); + // create appropriate descriptor + if (descriptorNodeRef != null) + { + Map properties = nodeService.getProperties(descriptorNodeRef); + return new RepositoryDescriptor(properties); + } + else + { + // descriptor cannot be found + return new UnknownDescriptor(); + } + } + /** * Push the current server descriptor properties into persistence. * @@ -284,33 +311,32 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList */ private NodeRef getDescriptorNodeRef(StoreRef storeRef, String path, boolean create) { - // check for the store and create if necessary - if (!nodeService.exists(storeRef) && create) - { - storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier()); - } - - String searchPath = "/" + path; NodeRef descriptorNodeRef = null; - NodeRef rootNodeRef = nodeService.getRootNode(storeRef); - List nodeRefs = searchService.selectNodes(rootNodeRef, searchPath, null, namespaceService, false); - if (nodeRefs.size() == 1) + String searchPath = "/" + path; + + // check for the store + if (nodeService.exists(storeRef)) { - descriptorNodeRef = nodeRefs.get(0); - } - else if (nodeRefs.size() == 0) - { - } - else if (nodeRefs.size() > 1) - { - if (logger.isDebugEnabled()) + NodeRef rootNodeRef = nodeService.getRootNode(storeRef); + List nodeRefs = searchService.selectNodes(rootNodeRef, searchPath, null, namespaceService, false); + if (nodeRefs.size() == 1) { - logger.debug("Multiple descriptors: \n" + - " store: " + storeRef + "\n" + - " path: " + searchPath); + descriptorNodeRef = nodeRefs.get(0); + } + else if (nodeRefs.size() == 0) + { + } + else if (nodeRefs.size() > 1) + { + if (logger.isDebugEnabled()) + { + logger.debug("Multiple descriptors: \n" + + " store: " + storeRef + "\n" + + " path: " + searchPath); + } + // get the first one + descriptorNodeRef = nodeRefs.get(0); } - // get the first one - descriptorNodeRef = nodeRefs.get(0); } if (descriptorNodeRef == null) @@ -321,9 +347,12 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList " store: " + storeRef + "\n" + " path: " + searchPath); } + // create if necessary if (create) { + storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier()); + NodeRef rootNodeRef = nodeService.getRootNode(storeRef); descriptorNodeRef = nodeService.createNode( rootNodeRef, ContentModel.ASSOC_CHILDREN, @@ -348,8 +377,8 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList // NOTE: We could tie in the License Component via Spring configuration, but then it could // be declaratively taken out in an installed environment. Class licenseComponentClass = Class.forName("org.alfresco.license.LicenseComponent"); - Constructor constructor = licenseComponentClass.getConstructor(new Class[] { ApplicationContext.class} ); - licenseService = (LicenseService)constructor.newInstance(new Object[] { applicationContext } ); + Constructor constructor = licenseComponentClass.getConstructor(new Class[] { ApplicationContext.class, Descriptor.class} ); + licenseService = (LicenseService)constructor.newInstance(new Object[] { applicationContext, createCurrentRepositoryDescriptor() } ); } catch (ClassNotFoundException e) { diff --git a/source/java/org/alfresco/repo/importer/ImporterBootstrap.java b/source/java/org/alfresco/repo/importer/ImporterBootstrap.java index 0c17c9d103..e03b9b512b 100644 --- a/source/java/org/alfresco/repo/importer/ImporterBootstrap.java +++ b/source/java/org/alfresco/repo/importer/ImporterBootstrap.java @@ -85,6 +85,10 @@ public class ImporterBootstrap implements ApplicationListener private Locale locale = null; private AuthenticationComponent authenticationComponent; + // Bootstrap performed? + private boolean bootstrapPerformed = false; + + /** * Set whether we write or not * @@ -263,6 +267,16 @@ public class ImporterBootstrap implements ApplicationListener { this.logEnabled = logEnabled; } + + /** + * Determine if bootstrap was performed? + * + * @return true => bootstrap was performed + */ + public boolean hasPerformedBootstrap() + { + return bootstrapPerformed; + } /** * Boostrap the Repository @@ -394,6 +408,9 @@ public class ImporterBootstrap implements ApplicationListener } } } + + // a bootstrap was performed + bootstrapPerformed = !useExistingStore; } userTransaction.commit(); } diff --git a/source/java/org/alfresco/service/descriptor/DescriptorService.java b/source/java/org/alfresco/service/descriptor/DescriptorService.java index 54f13a3d7d..f1695228ed 100644 --- a/source/java/org/alfresco/service/descriptor/DescriptorService.java +++ b/source/java/org/alfresco/service/descriptor/DescriptorService.java @@ -44,9 +44,9 @@ public interface DescriptorService public Descriptor getInstalledRepositoryDescriptor(); /** - * Gets the License Service + * Gets the License Descriptor * - * @return the license service + * @return the license descriptor */ public LicenseDescriptor getLicenseDescriptor();