Merge from SEAMIST3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10718 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2008-09-04 10:40:14 +00:00
parent 859bb904f2
commit f50701a46c
7 changed files with 147 additions and 19 deletions

View File

@@ -399,6 +399,9 @@
<!-- Descriptor Service --> <!-- Descriptor Service -->
<bean id="descriptorComponent" class="org.alfresco.repo.descriptor.DescriptorServiceImpl"> <bean id="descriptorComponent" class="org.alfresco.repo.descriptor.DescriptorServiceImpl">
<property name="repositoryName">
<value>${repository.name}</value>
</property>
<property name="descriptor"> <property name="descriptor">
<value>classpath:alfresco/version.properties</value> <value>classpath:alfresco/version.properties</value>
</property> </property>

View File

@@ -28,6 +28,10 @@
<title>Descriptor</title> <title>Descriptor</title>
<parent>sys:base</parent> <parent>sys:base</parent>
<properties> <properties>
<property name="sys:name">
<type>d:text</type>
<mandatory enforced="true">true</mandatory>
</property>
<property name="sys:versionMajor"> <property name="sys:versionMajor">
<type>d:text</type> <type>d:text</type>
<mandatory enforced="true">true</mandatory> <mandatory enforced="true">true</mandatory>

View File

@@ -1,3 +1,7 @@
# Repository configuration
repository.name=Main Repository
# Directory configuration # Directory configuration
dir.root=./alf_data dir.root=./alf_data

View File

@@ -84,6 +84,7 @@ public interface ContentModel
static final QName TYPE_STOREROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store_root"); static final QName TYPE_STOREROOT = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "store_root");
// descriptor properties // 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_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_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"); static final QName PROP_SYS_VERSION_REVISION = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "versionRevision");

View File

@@ -28,6 +28,8 @@ import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@@ -66,6 +68,7 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
{ {
private static Log logger = LogFactory.getLog(DescriptorServiceImpl.class); private static Log logger = LogFactory.getLog(DescriptorServiceImpl.class);
private String repositoryName;
private Properties serverProperties; private Properties serverProperties;
private ImporterBootstrap systemBootstrap; private ImporterBootstrap systemBootstrap;
@@ -82,8 +85,23 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
private Descriptor serverDescriptor; private Descriptor serverDescriptor;
private Descriptor currentRepoDescriptor;
private Descriptor installedRepoDescriptor; 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 * Sets the server descriptor from a resource file
* *
@@ -155,6 +173,14 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.alfresco.service.descriptor.DescriptorService#getCurrentRepositoryDescriptor()
*/
public Descriptor getCurrentRepositoryDescriptor()
{
return currentRepoDescriptor;
}
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.DescriptorService#getRepositoryDescriptor() * @see org.alfresco.service.descriptor.DescriptorService#getRepositoryDescriptor()
*/ */
public Descriptor getInstalledRepositoryDescriptor() public Descriptor getInstalledRepositoryDescriptor()
@@ -188,9 +214,9 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
licenseService.verifyLicense(); licenseService.verifyLicense();
// persist the server descriptor values // persist the server descriptor values
updateCurrentRepositoryDescriptor(serverDescriptor); currentRepoDescriptor = updateCurrentRepositoryDescriptor(serverDescriptor);
// return the repository installed descriptor // create the installed descriptor
return createInstalledRepositoryDescriptor(); return createInstalledRepositoryDescriptor();
} }
}; };
@@ -258,7 +284,7 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
* @param serverDescriptor * @param serverDescriptor
* the current server descriptor * the current server descriptor
*/ */
private void updateCurrentRepositoryDescriptor(Descriptor serverDescriptor) private Descriptor updateCurrentRepositoryDescriptor(Descriptor serverDescriptor)
{ {
// retrieve system descriptor location // retrieve system descriptor location
StoreRef storeRef = systemBootstrap.getStoreRef(); StoreRef storeRef = systemBootstrap.getStoreRef();
@@ -270,18 +296,22 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
// if the node is missing but it should have been created // if the node is missing but it should have been created
if (currentDescriptorNodeRef == null) if (currentDescriptorNodeRef == null)
{ {
return; return null;
} }
// set the properties // set the properties
if (!transactionService.isReadOnly()) if (!transactionService.isReadOnly())
{ {
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_MAJOR, serverDescriptor.getVersionMajor());
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_MINOR, serverDescriptor.getVersionMinor()); 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_REVISION, serverDescriptor.getVersionRevision());
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_LABEL, serverDescriptor.getVersionLabel()); 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_BUILD, serverDescriptor.getVersionBuild());
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_SCHEMA, serverDescriptor.getSchema()); nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_SCHEMA, serverDescriptor.getSchema());
} Collection<String> editions = new ArrayList<String>();
editions.add(serverDescriptor.getEdition());
nodeService.setProperty(currentDescriptorNodeRef, ContentModel.PROP_SYS_VERSION_EDITION, (Serializable)editions);
// done // done
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -289,6 +319,10 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
} }
} }
Map<QName, Serializable> properties = nodeService.getProperties(currentDescriptorNodeRef);
return new RepositoryDescriptor(properties);
}
/** /**
* @param storeRef * @param storeRef
* the store to search * the store to search
@@ -431,6 +465,22 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
/* /*
* (non-Javadoc) * (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() * @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
*/ */
public String getVersionMajor() public String getVersionMajor()
@@ -660,6 +710,22 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
/* /*
* (non-Javadoc) * (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() * @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
*/ */
public String getVersionMajor() public String getVersionMajor()
@@ -714,7 +780,7 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
*/ */
public String getEdition() public String getEdition()
{ {
return null; return getDescriptor("sys:versionEdition");
} }
/* /*
@@ -750,9 +816,20 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
QName qname = QName.createQName(key, namespaceService); QName qname = QName.createQName(key, namespaceService);
Serializable value = properties.get(qname); Serializable value = properties.get(qname);
if (value != null) if (value != null)
{
if (value instanceof Collection)
{
Collection coll = (Collection)value;
if (coll.size() > 0)
{
strValue = coll.iterator().next().toString();
}
}
else
{ {
strValue = value.toString(); strValue = value.toString();
} }
}
return strValue; return strValue;
} }
} }
@@ -765,6 +842,22 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
/* /*
* (non-Javadoc) * (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 repositoryName == null ? "<Unknown>" : repositoryName;
}
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.Descriptor#getVersionMajor() * @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
*/ */
public String getVersionMajor() public String getVersionMajor()

View File

@@ -34,6 +34,20 @@ import org.alfresco.util.VersionNumber;
*/ */
public interface Descriptor 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. <u>1</u>.2.3 * Gets the major version number, e.g. <u>1</u>.2.3
* *

View File

@@ -46,13 +46,22 @@ public interface DescriptorService
public Descriptor getServerDescriptor(); public Descriptor getServerDescriptor();
/** /**
* Get descriptor for the repository as it was when first installed. The current * Get descriptor for the repository as it is currently installed.
* repository descriptor will always be the same as the *
* The current repository descriptor will always be the same as the
* {@link #getServerDescriptor() server descriptor}. * {@link #getServerDescriptor() server descriptor}.
* *
* @return repository descriptor * @return repository descriptor
*/ */
@NotAuditable @NotAuditable
public Descriptor getCurrentRepositoryDescriptor();
/**
* Get descriptor for the repository as it was when first installed.
*
* @return repository descriptor
*/
@NotAuditable
public Descriptor getInstalledRepositoryDescriptor(); public Descriptor getInstalledRepositoryDescriptor();
/** /**