From f50701a46c5be5da5b412d7e4beb3cc9ba0cd0df Mon Sep 17 00:00:00 2001 From: David Caruana Date: Thu, 4 Sep 2008 10:40:14 +0000 Subject: [PATCH] Merge from SEAMIST3 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10718 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/bootstrap-context.xml | 3 + config/alfresco/model/systemModel.xml | 4 + config/alfresco/repository.properties | 4 + .../java/org/alfresco/model/ContentModel.java | 1 + .../descriptor/DescriptorServiceImpl.java | 127 +++++++++++++++--- .../service/descriptor/Descriptor.java | 14 ++ .../service/descriptor/DescriptorService.java | 13 +- 7 files changed, 147 insertions(+), 19 deletions(-) diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 90d5f0a5e5..0800298d6e 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -399,6 +399,9 @@ + + ${repository.name} + classpath:alfresco/version.properties diff --git a/config/alfresco/model/systemModel.xml b/config/alfresco/model/systemModel.xml index 053854ab59..5ecfb884c1 100644 --- a/config/alfresco/model/systemModel.xml +++ b/config/alfresco/model/systemModel.xml @@ -28,6 +28,10 @@ Descriptor sys:base + + d:text + true + d:text true diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index 360c80ab84..98deab4120 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -1,3 +1,7 @@ +# Repository configuration + +repository.name=Main Repository + # Directory configuration dir.root=./alf_data diff --git a/source/java/org/alfresco/model/ContentModel.java b/source/java/org/alfresco/model/ContentModel.java index 3c94de0946..5c8cacc96f 100644 --- a/source/java/org/alfresco/model/ContentModel.java +++ b/source/java/org/alfresco/model/ContentModel.java @@ -84,6 +84,7 @@ public interface ContentModel static final QName TYPE_STOREROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store_root"); // descriptor properties + static final QName PROP_SYS_NAME = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "name"); static final QName PROP_SYS_VERSION_MAJOR = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionMajor"); static final QName PROP_SYS_VERSION_MINOR = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionMinor"); static final QName PROP_SYS_VERSION_REVISION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionRevision"); diff --git a/source/java/org/alfresco/repo/descriptor/DescriptorServiceImpl.java b/source/java/org/alfresco/repo/descriptor/DescriptorServiceImpl.java index 8d0d86475a..1d6ba9ef29 100644 --- a/source/java/org/alfresco/repo/descriptor/DescriptorServiceImpl.java +++ b/source/java/org/alfresco/repo/descriptor/DescriptorServiceImpl.java @@ -28,6 +28,8 @@ import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Properties; @@ -66,6 +68,7 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc { private static Log logger = LogFactory.getLog(DescriptorServiceImpl.class); + private String repositoryName; private Properties serverProperties; private ImporterBootstrap systemBootstrap; @@ -82,8 +85,23 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc private Descriptor serverDescriptor; + private Descriptor currentRepoDescriptor; + private Descriptor installedRepoDescriptor; + + /** + * Sets the repository properties from a resource file + * + * @param repositoryResource resource containing repository properties + * @throws IOException + */ + public void setRepositoryName(String repositoryName) + throws IOException + { + this.repositoryName = repositoryName; + } + /** * Sets the server descriptor from a resource file * @@ -155,6 +173,14 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc /* * (non-Javadoc) * + * @see org.alfresco.service.descriptor.DescriptorService#getCurrentRepositoryDescriptor() + */ + public Descriptor getCurrentRepositoryDescriptor() + { + return currentRepoDescriptor; + } + + /* (non-Javadoc) * @see org.alfresco.service.descriptor.DescriptorService#getRepositoryDescriptor() */ public Descriptor getInstalledRepositoryDescriptor() @@ -188,9 +214,9 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc licenseService.verifyLicense(); // persist the server descriptor values - updateCurrentRepositoryDescriptor(serverDescriptor); + currentRepoDescriptor = updateCurrentRepositoryDescriptor(serverDescriptor); - // return the repository installed descriptor + // create the installed descriptor return createInstalledRepositoryDescriptor(); } }; @@ -258,7 +284,7 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc * @param serverDescriptor * the current server descriptor */ - private void updateCurrentRepositoryDescriptor(Descriptor serverDescriptor) + private Descriptor updateCurrentRepositoryDescriptor(Descriptor serverDescriptor) { // retrieve system descriptor location StoreRef storeRef = systemBootstrap.getStoreRef(); @@ -270,23 +296,31 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc // if the node is missing but it should have been created if (currentDescriptorNodeRef == null) { - return; + return null; } // set the properties if (!transactionService.isReadOnly()) { - nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MAJOR, serverDescriptor.getVersionMajor()); - nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MINOR, serverDescriptor.getVersionMinor()); - nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_REVISION, serverDescriptor.getVersionRevision()); - nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_LABEL, serverDescriptor.getVersionLabel()); - nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_BUILD, serverDescriptor.getVersionBuild()); - nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_SCHEMA, serverDescriptor.getSchema()); - } - // done - if (logger.isDebugEnabled()) - { - logger.debug("Updated current repository descriptor properties: \n" + " node: " + currentDescriptorNodeRef + "\n" + " descriptor: " + serverDescriptor); + nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_NAME, serverDescriptor.getName()); + nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MAJOR, serverDescriptor.getVersionMajor()); + nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MINOR, serverDescriptor.getVersionMinor()); + nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_REVISION, serverDescriptor.getVersionRevision()); + nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_LABEL, serverDescriptor.getVersionLabel()); + nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_BUILD, serverDescriptor.getVersionBuild()); + nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_SCHEMA, serverDescriptor.getSchema()); + Collection editions = new ArrayList(); + editions.add(serverDescriptor.getEdition()); + nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_EDITION, (Serializable)editions); + + // done + if (logger.isDebugEnabled()) + { + logger.debug("Updated current repository descriptor properties: \n" + " node: " + currentDescriptorNodeRef + "\n" + " descriptor: " + serverDescriptor); + } } + + Map properties = nodeService.getProperties(currentDescriptorNodeRef); + return new RepositoryDescriptor(properties); } /** @@ -431,6 +465,22 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc /* * (non-Javadoc) * + * @see org.alfresco.service.descriptor.Descriptor#getId() + */ + public String getId() + { + return "Unknown"; + } + + /* (non-Javadoc) + * @see org.alfresco.service.descriptor.Descriptor#getName() + */ + public String getName() + { + return "Unknown"; + } + + /* (non-Javadoc) * @see org.alfresco.service.descriptor.Descriptor#getVersionMajor() */ public String getVersionMajor() @@ -660,6 +710,22 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc /* * (non-Javadoc) * + * @see org.alfresco.service.descriptor.Descriptor#getId() + */ + public String getId() + { + return getDescriptor("sys:node-uuid"); + } + + /* (non-Javadoc) + * @see org.alfresco.service.descriptor.Descriptor#getName() + */ + public String getName() + { + return getDescriptor("sys:name"); + } + + /* (non-Javadoc) * @see org.alfresco.service.descriptor.Descriptor#getVersionMajor() */ public String getVersionMajor() @@ -714,7 +780,7 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc */ public String getEdition() { - return null; + return getDescriptor("sys:versionEdition"); } /* @@ -751,7 +817,18 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc Serializable value = properties.get(qname); if (value != null) { - strValue = value.toString(); + if (value instanceof Collection) + { + Collection coll = (Collection)value; + if (coll.size() > 0) + { + strValue = coll.iterator().next().toString(); + } + } + else + { + strValue = value.toString(); + } } return strValue; } @@ -765,6 +842,22 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc /* * (non-Javadoc) * + * @see org.alfresco.service.descriptor.Descriptor#getId() + */ + public String getId() + { + return "" : repositoryName; + } + + /* (non-Javadoc) * @see org.alfresco.service.descriptor.Descriptor#getVersionMajor() */ public String getVersionMajor() diff --git a/source/java/org/alfresco/service/descriptor/Descriptor.java b/source/java/org/alfresco/service/descriptor/Descriptor.java index 8fcaabeca4..b3efbfb540 100644 --- a/source/java/org/alfresco/service/descriptor/Descriptor.java +++ b/source/java/org/alfresco/service/descriptor/Descriptor.java @@ -34,6 +34,20 @@ import org.alfresco.util.VersionNumber; */ public interface Descriptor { + /** + * Gets the id of the item being described + * + * @return identifier + */ + public String getId(); + + /** + * Gets the name of the item being described + * + * @return name + */ + public String getName(); + /** * Gets the major version number, e.g. 1.2.3 * diff --git a/source/java/org/alfresco/service/descriptor/DescriptorService.java b/source/java/org/alfresco/service/descriptor/DescriptorService.java index d310a69cfe..fbc117be98 100644 --- a/source/java/org/alfresco/service/descriptor/DescriptorService.java +++ b/source/java/org/alfresco/service/descriptor/DescriptorService.java @@ -46,13 +46,22 @@ public interface DescriptorService public Descriptor getServerDescriptor(); /** - * Get descriptor for the repository as it was when first installed. The current - * repository descriptor will always be the same as the + * Get descriptor for the repository as it is currently installed. + * + * The current repository descriptor will always be the same as the * {@link #getServerDescriptor() server descriptor}. * * @return repository descriptor */ @NotAuditable + public Descriptor getCurrentRepositoryDescriptor(); + + /** + * Get descriptor for the repository as it was when first installed. + * + * @return repository descriptor + */ + @NotAuditable public Descriptor getInstalledRepositoryDescriptor(); /**