Big honkin' merge from head. Sheesh!

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-08-27 01:01:30 +00:00
parent e2c66899cc
commit 8031cc6574
322 changed files with 20776 additions and 6550 deletions

View File

@@ -44,6 +44,7 @@ import org.alfresco.service.transaction.TransactionService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -58,7 +59,7 @@ import org.springframework.core.io.Resource;
*
* @author David Caruana
*/
public class DescriptorServiceImpl implements DescriptorService, ApplicationListener, InitializingBean, ApplicationContextAware
public class DescriptorServiceImpl implements DescriptorService, ApplicationListener, InitializingBean, ApplicationContextAware, DisposableBean
{
private static Log logger = LogFactory.getLog(DescriptorServiceImpl.class);
@@ -201,6 +202,13 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
serverDescriptor = createServerDescriptor();
}
/**
* Destruction hook
*/
public void destroy() throws Exception
{
}
/**
* Create server descriptor
*
@@ -262,6 +270,7 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
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
@@ -441,6 +450,14 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
return "Unknown";
}
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.Descriptor#getVersionBuild()
*/
public String getVersionBuild()
{
return "Unknown";
}
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
*/
@@ -483,14 +500,99 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
}
}
/**
* Base class for Descriptor implementations, provides a
* default getVersion() implementation.
*
* @author gavinc
*/
public abstract class BaseDescriptor implements Descriptor
{
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
*/
public String getVersion()
{
StringBuilder version = new StringBuilder(getVersionMajor());
version.append(".");
version.append(getVersionMinor());
version.append(".");
version.append(getVersionRevision());
String label = getVersionLabel();
String build = getVersionBuild();
boolean hasLabel = (label != null && label.length() > 0);
boolean hasBuild = (build != null && build.length() > 0);
// add opening bracket if either a label or build number is present
if (hasLabel || hasBuild)
{
version.append(" (");
}
// add label if present
if (hasLabel)
{
version.append(label);
}
// add build number is present
if (hasBuild)
{
// if there is also a label we need a separating space
if (hasLabel)
{
version.append(" ");
}
version.append(build);
}
// add closing bracket if either a label or build number is present
if (hasLabel || hasBuild)
{
version.append(")");
}
return version.toString();
}
/**
* Returns the int representation of the given schema string
*
* @param schemaStr The schema number as a string
* @return The schema number as an int
*/
protected int getSchema(String schemaStr)
{
if (schemaStr == null)
{
return 0;
}
try
{
int schema = Integer.parseInt(schemaStr);
if (schema < 0)
{
throw new NumberFormatException();
}
return schema;
}
catch (NumberFormatException e)
{
throw new AlfrescoRuntimeException("Schema must be a positive integer '" + schemaStr + "' is not!");
}
}
}
/**
* Repository Descriptor whose meta-data is retrieved from the repository store
*/
private class RepositoryDescriptor implements Descriptor
private class RepositoryDescriptor extends BaseDescriptor
{
private Map<QName, Serializable> properties;
/**
* Construct
*
@@ -534,17 +636,11 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
}
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
* @see org.alfresco.service.descriptor.Descriptor#getVersionBuild()
*/
public String getVersion()
public String getVersionBuild()
{
String version = getVersionMajor() + "." + getVersionMinor() + "." + getVersionRevision();
String label = getVersionLabel();
if (label != null && label.length() > 0)
{
version += " (" + label + ")";
}
return version;
return getDescriptor("sys:versionBuild");
}
/* (non-Javadoc)
@@ -561,24 +657,7 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
*/
public int getSchema()
{
String schemaStr = getDescriptor("sys:versionSchema");
if (schemaStr == null)
{
return 0;
}
try
{
int schema = Integer.parseInt(schemaStr);
if (schema < 0)
{
throw new NumberFormatException();
}
return schema;
}
catch (NumberFormatException e)
{
throw new AlfrescoRuntimeException("'version.schema' must be a positive integer");
}
return getSchema(getDescriptor("sys:versionSchema"));
}
/* (non-Javadoc)
@@ -610,7 +689,7 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
/**
* Server Descriptor whose meta-data is retrieved from run-time environment
*/
private class ServerDescriptor implements Descriptor
private class ServerDescriptor extends BaseDescriptor
{
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.Descriptor#getVersionMajor()
@@ -643,19 +722,13 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
{
return serverProperties.getProperty("version.label");
}
/* (non-Javadoc)
* @see org.alfresco.service.descriptor.Descriptor#getVersion()
* @see org.alfresco.service.descriptor.Descriptor#getVersionBuild()
*/
public String getVersion()
public String getVersionBuild()
{
String version = getVersionMajor() + "." + getVersionMinor() + "." + getVersionRevision();
String label = getVersionLabel();
if (label != null && label.length() > 0)
{
version += " (" + label + ")";
}
return version;
return serverProperties.getProperty("version.build");
}
/* (non-Javadoc)
@@ -672,24 +745,7 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
*/
public int getSchema()
{
String schemaStr = serverProperties.getProperty("version.schema");
if (schemaStr == null)
{
return 0;
}
try
{
int schema = Integer.parseInt(schemaStr);
if (schema < 0)
{
throw new NumberFormatException();
}
return schema;
}
catch (NumberFormatException e)
{
throw new AlfrescoRuntimeException("'version.schema' must be a positive integer");
}
return getSchema(serverProperties.getProperty("version.schema"));
}
/* (non-Javadoc)
@@ -710,5 +766,4 @@ public class DescriptorServiceImpl implements DescriptorService, ApplicationList
return serverProperties.getProperty(key, "");
}
}
}

View File

@@ -72,11 +72,9 @@ public class DescriptorServiceTest extends BaseSpringTest
String minor = serverDescriptor.getVersionMinor();
String revision = serverDescriptor.getVersionRevision();
String label = serverDescriptor.getVersionLabel();
String build = serverDescriptor.getVersionBuild();
String version = major + "." + minor + "." + revision;
if (label != null && label.length() > 0)
{
version += " (" + label + ")";
}
version = buildVersionString(version, label, build);
assertEquals(version, serverDescriptor.getVersion());
@@ -94,11 +92,9 @@ public class DescriptorServiceTest extends BaseSpringTest
String minor = repoDescriptor.getVersionMinor();
String revision = repoDescriptor.getVersionRevision();
String label = repoDescriptor.getVersionLabel();
String build = repoDescriptor.getVersionBuild();
String version = major + "." + minor + "." + revision;
if (label != null && label.length() > 0)
{
version += " (" + label + ")";
}
version = buildVersionString(version, label, build);
assertEquals(version, repoDescriptor.getVersion());
@@ -106,4 +102,43 @@ public class DescriptorServiceTest extends BaseSpringTest
assertTrue("Repository schema version must be greater than -1", schemaVersion > -1);
}
private String buildVersionString(String version, String label, String build)
{
StringBuilder builder = new StringBuilder(version);
boolean hasLabel = (label != null && label.length() > 0);
boolean hasBuild = (build != null && build.length() > 0);
// add opening bracket if either a label or build number is present
if (hasLabel || hasBuild)
{
builder.append(" (");
}
// add label if present
if (hasLabel)
{
builder.append(label);
}
// add build number is present
if (hasBuild)
{
// if there is also a label we need a separating space
if (hasLabel)
{
builder.append(" ");
}
builder.append(build);
}
// add closing bracket if either a label or build number is present
if (hasLabel || hasBuild)
{
builder.append(")");
}
return builder.toString();
}
}