Merged V2.0 to HEAD

5457: Merge error on copy web project action
   5459: AR-1278
   5461:
   5462: A few deployment fixes
   5469: Dictionary messages
   5470: L2 cache checks
   5478: WCM-374


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5485 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-04-12 02:02:42 +00:00
parent 138d1780cb
commit 0570c77f46
16 changed files with 473 additions and 221 deletions

View File

@@ -46,40 +46,48 @@ import org.springframework.beans.PropertyAccessException;
*
* @author Derek Hulley
*/
/*package*/ class M2ConstraintDefinition implements ConstraintDefinition
/* package */class M2ConstraintDefinition implements ConstraintDefinition
{
public static final String ERR_CYCLIC_REF = "d_dictionary.constraint.err.cyclic_ref";
public static final String ERR_TYPE_AND_REF = "d_dictionary.constraint.err.type_and_ref";
public static final String ERR_TYPE_OR_REF = "d_dictionary.constraint.err.type_or_ref";
public static final String ERR_REF_NOT_FOUND = "d_dictionary.constraint.err.ref_not_found";
public static final String ERR_ANON_NEEDS_PROPERTY = "d_dictionary.constraint.err.anon_needs_property";
public static final String ERR_INVALID_TYPE = "d_dictionary.constraint.err.invalid_type";
public static final String ERR_SIMPLE_AND_LIST = "d_dictionary.constraint.err.property_simple_and_list";
public static final String ERR_CONSTRUCT_FAILURE = "d_dictionary.constraint.err.construct_failure";
public static final String ERR_PROPERTY_MISMATCH = "d_dictionary.constraint.err.property_mismatch";
private static int anonPropCount = 0;
private ModelDefinition model;
private NamespacePrefixResolver prefixResolver;
private M2Constraint m2Constraint;
private QName name;
private Constraint constraint;
private boolean resolving;
/*package*/ M2ConstraintDefinition(
M2PropertyDefinition m2PropertyDef,
M2Constraint m2Constraint,
/* package */M2ConstraintDefinition(M2PropertyDefinition m2PropertyDef, M2Constraint m2Constraint,
NamespacePrefixResolver prefixResolver)
{
this(m2PropertyDef.getModel(), m2PropertyDef, m2Constraint, prefixResolver);
}
/*package*/ M2ConstraintDefinition(
ModelDefinition modelDefinition,
M2PropertyDefinition m2PropertyDef,
M2Constraint m2Constraint,
NamespacePrefixResolver prefixResolver)
/* package */M2ConstraintDefinition(ModelDefinition modelDefinition, M2PropertyDefinition m2PropertyDef,
M2Constraint m2Constraint, NamespacePrefixResolver prefixResolver)
{
this.model = modelDefinition;
this.m2Constraint = m2Constraint;
@@ -103,8 +111,8 @@ import org.springframework.beans.PropertyAccessException;
this.name = QName.createQName(m2Constraint.getName(), prefixResolver);
}
}
/*package*/ synchronized void resolveDependencies(ModelQuery query)
/* package */synchronized void resolveDependencies(ModelQuery query)
{
if (resolving)
{
@@ -121,7 +129,7 @@ import org.springframework.beans.PropertyAccessException;
resolving = false;
}
}
private synchronized void resolveInternal(ModelQuery query)
{
if (constraint != null)
@@ -187,39 +195,43 @@ import org.springframework.beans.PropertyAccessException;
// property setters
BeanWrapper beanWrapper = new BeanWrapperImpl(constraint);
List<M2NamedValue> constraintNamedValues = m2Constraint.getParameters();
for (M2NamedValue namedValue : constraintNamedValues)
if (constraintNamedValues != null)
{
Object value = null;
if (namedValue.getSimpleValue() != null && namedValue.getListValue() != null)
for (M2NamedValue namedValue : constraintNamedValues)
{
throw new DictionaryException(ERR_SIMPLE_AND_LIST, shortName, namedValue.getName());
}
else if (namedValue.getSimpleValue() != null)
{
value = namedValue.getSimpleValue();
}
else if (namedValue.getListValue() != null)
{
value = namedValue.getListValue();
}
try
{
beanWrapper.setPropertyValue(namedValue.getName(), value);
}
catch (PropertyAccessException e)
{
throw new DictionaryException(ERR_PROPERTY_MISMATCH, e, namedValue.getName(), shortName);
}
catch (InvalidPropertyException e)
{
throw new DictionaryException(ERR_PROPERTY_MISMATCH, e, namedValue.getName(), shortName);
Object value = null;
if (namedValue.getSimpleValue() != null && namedValue.getListValue() != null)
{
throw new DictionaryException(ERR_SIMPLE_AND_LIST, shortName, namedValue.getName());
}
else if (namedValue.getSimpleValue() != null)
{
value = namedValue.getSimpleValue();
}
else if (namedValue.getListValue() != null)
{
value = namedValue.getListValue();
}
try
{
beanWrapper.setPropertyValue(namedValue.getName(), value);
}
catch (PropertyAccessException e)
{
throw new DictionaryException(ERR_PROPERTY_MISMATCH, e, namedValue.getName(), shortName);
}
catch (InvalidPropertyException e)
{
throw new DictionaryException(ERR_PROPERTY_MISMATCH, e, namedValue.getName(), shortName);
}
}
}
// now initialize
constraint.initialize();
}
}
/**
* @see #getName()
*/
@@ -228,7 +240,7 @@ import org.springframework.beans.PropertyAccessException;
{
return getName().toString();
}
public ModelDefinition getModel()
{
return model;
@@ -243,7 +255,7 @@ import org.springframework.beans.PropertyAccessException;
{
return constraint;
}
/**
* Well-known constraint types
*/

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.repo.dictionary.constraint;
import org.alfresco.service.cmr.dictionary.ConstraintException;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
import org.alfresco.service.cmr.security.AuthorityType;
public class AuthorityNameConstraint extends AbstractConstraint
{
private static final String ERR_INVALID_AUTHORITY_NAME = "d_dictionary.constraint.authority_name.invalid_authority_name";
private static final String ERR_NON_STRING = "d_dictionary.constraint.authority_name.non_string";
@Override
protected void evaluateSingleValue(Object value)
{
// ensure that the value can be converted to a String
String checkValue = null;
try
{
checkValue = DefaultTypeConverter.INSTANCE.convert(String.class, value);
}
catch (TypeConversionException e)
{
throw new ConstraintException(ERR_NON_STRING, value);
}
AuthorityType type = AuthorityType.getAuthorityType(checkValue);
if((type != AuthorityType.GROUP) && (type != AuthorityType.ROLE))
{
throw new ConstraintException(ERR_INVALID_AUTHORITY_NAME, value, type);
}
}
public void initialize()
{
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.repo.dictionary.constraint;
import org.alfresco.service.cmr.dictionary.ConstraintException;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
import org.alfresco.service.cmr.security.AuthorityType;
/**
* Apply constraints for user names.
*
* @author andyh
*
*/
public class UserNameConstraint extends AbstractConstraint
{
private static final String ERR_INVALID_USERNAME = "d_dictionary.constraint.user_name.invalid_user_name";
private static final String ERR_NON_STRING = "d_dictionary.constraint.user_name.non_string";
@Override
protected void evaluateSingleValue(Object value)
{
// ensure that the value can be converted to a String
String checkValue = null;
try
{
checkValue = DefaultTypeConverter.INSTANCE.convert(String.class, value);
}
catch (TypeConversionException e)
{
throw new ConstraintException(ERR_NON_STRING, value);
}
AuthorityType type = AuthorityType.getAuthorityType(checkValue);
if((type != AuthorityType.USER) && (type != AuthorityType.GUEST))
{
throw new ConstraintException(ERR_INVALID_USERNAME, value, type);
}
}
public void initialize()
{
}
}