本文整理汇总了Java中org.alfresco.service.cmr.dictionary.ConstraintException类的典型用法代码示例。如果您正苦于以下问题:Java ConstraintException类的具体用法?Java ConstraintException怎么用?Java ConstraintException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstraintException类属于org.alfresco.service.cmr.dictionary包,在下文中一共展示了ConstraintException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
@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);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:AuthorityNameConstraint.java
示例2: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
@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);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:UserNameConstraint.java
示例3: getRawAllowedValues
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
@Override
public List<String> getRawAllowedValues()
{
List<String> result = null;
try
{
result = loadClasspathTemplates(templatesParentClasspath,
"json");
}
catch (IOException e)
{
throw new ConstraintException("ListTemplateTypesConstraints",
e);
}
List<String> repositoryTemplates = loadRepositoryTemplates(templatesParentRepositoryPath);
result.addAll(repositoryTemplates);
if (result.size() == 0)
{
result.add(NULL_SYSTEM_TEMPLATE);
}
super.setAllowedValues(result);
return result;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:SystemTemplateLocationsConstraint.java
示例4: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
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);
}
// Check that the value length
int length = checkValue.length();
if (length > maxLength || length < minLength)
{
if (length > 20)
{
checkValue = checkValue.substring(0, 17) + "...";
}
throw new ConstraintException(ERR_INVALID_LENGTH, checkValue, minLength, maxLength);
}
}
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:25,代码来源:StringLengthConstraint.java
示例5: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
protected void evaluateSingleValue(Object value)
{
// ensure that the value can be converted to a double
double checkValue = Double.NaN;
try
{
checkValue = DefaultTypeConverter.INSTANCE.doubleValue(value);
}
catch (NumberFormatException e)
{
throw new ConstraintException(ERR_NON_NUMERIC, value);
}
// Infinity and NaN cannot match
if (Double.isInfinite(checkValue) || Double.isNaN(checkValue))
{
throw new ConstraintException(ERR_OUT_OF_RANGE, checkValue, minValue, maxValue);
}
// Check that the value is in range
if (checkValue > maxValue || checkValue < minValue)
{
throw new ConstraintException(ERR_OUT_OF_RANGE, checkValue, minValue, maxValue);
}
}
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:26,代码来源:NumericRangeConstraint.java
示例6: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
protected void evaluateSingleValue(Object value)
{
// convert the value to a String
String valueStr = DefaultTypeConverter.INSTANCE.convert(String.class, value);
Matcher matcher = patternMatcher.matcher(valueStr);
boolean matches = matcher.matches();
if (matches != requiresMatch)
{
// Look for a message corresponding to this constraint name
String messageId = CONSTRAINT_REGEX_MSG_PREFIX + getShortName();
if (I18NUtil.getMessage(messageId, value) != null)
{
throw new ConstraintException(messageId, value);
}
// Otherwise, fall back to a generic (but unfriendly) message
else if (requiresMatch)
{
throw new ConstraintException(RegexConstraint.CONSTRAINT_REGEX_NO_MATCH, value, expression);
}
else
{
throw new ConstraintException(RegexConstraint.CONSTRAINT_REGEX_MATCH, value, expression);
}
}
}
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:26,代码来源:RegexConstraint.java
示例7: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
/**
* Fails on everything but String values, which pass.
* Null values cause runtime exceptions and all other failures are by
* DictionaryException.
*/
@Override
protected void evaluateSingleValue(Object value)
{
if (value == null)
{
throw new NullPointerException("Null value in dummy test");
}
else if (value instanceof String)
{
tested.add(value);
}
else
{
throw new ConstraintException("Non-String value");
}
}
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:22,代码来源:ConstraintsTest.java
示例8: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
/**
* @see org.alfresco.repo.dictionary.constraint.AbstractConstraint#evaluateSingleValue(java.lang.Object)
*/
@Override
protected void evaluateSingleValue(Object value)
{
// convert the value to a String
String valueStr = null;
try
{
valueStr = DefaultTypeConverter.INSTANCE.convert(String.class, value);
}
catch (TypeConversionException e)
{
throw new ConstraintException(ERR_NON_STRING, value);
}
// check that the value is in the set of allowed values
if (caseSensitive)
{
if (!allowedValuesSet.contains(valueStr))
{
throw new ConstraintException(ERR_INVALID_VALUE, value);
}
}
else
{
if (!allowedValuesUpperSet.contains(valueStr.toUpperCase()))
{
throw new ConstraintException(ERR_INVALID_VALUE, value);
}
}
}
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:33,代码来源:ListOfValuesConstraint.java
示例9: testCollections
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
/**
* ensure that the default handling of checks on collections will work
*/
public void testCollections() throws Exception
{
DummyConstraint constraint = new DummyConstraint();
constraint.initialize();
assertEquals("DummyConstraint type should be 'org.alfresco.repo.dictionary.constraint.ConstraintsTest$DummyConstraint'",
"org.alfresco.repo.dictionary.constraint.ConstraintsTest$DummyConstraint",
constraint.getType());
assertNotNull("DummyConstraint should not have empty parameters", constraint.getParameters());
assertEquals("DummyConstraint should not have empty parameters", 0, constraint.getParameters().size());
List<Object> dummyObjects = new ArrayList<Object>(3);
dummyObjects.add("ABC"); // correct
dummyObjects.add("DEF"); // correct
dummyObjects.add(this); // NO
try
{
constraint.evaluate(dummyObjects);
fail("Failed to detected constraint violation in collection");
}
catch (ConstraintException e)
{
// expected
checkI18NofExceptionMessage(e);
}
// check that the two strings were properly dealt with
assertEquals("String values not checked", 2, constraint.tested.size());
}
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:32,代码来源:ConstraintsTest.java
示例10: evaluate
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
private void evaluate(Constraint constraint, Object value, boolean expectFailure) throws Exception
{
try
{
constraint.evaluate(value);
if (expectFailure)
{
// it should have failed
fail("Failure did not occur: \n" +
" constraint: " + constraint + "\n" +
" value: " + value);
}
}
catch (ConstraintException e)
{
// check if we expect an error
if (expectFailure)
{
// expected - check message I18N
checkI18NofExceptionMessage(e);
}
else
{
// didn't expect it
throw e;
}
}
}
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:29,代码来源:ConstraintsTest.java
示例11: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
@Override
protected void evaluateSingleValue(Object value)
{
String checkValue = DefaultTypeConverter.INSTANCE.convert(String.class, value);
if (checkValue.contains("#"))
{
throw new ConstraintException("The value must not contain '#'");
}
}
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:11,代码来源:TestCustomConstraint.java
示例12: evaluateSingleValue
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
@Override
protected void evaluateSingleValue(Object value)
{
// convert the value to a String
String valueStr = null;
try
{
valueStr = DefaultTypeConverter.INSTANCE.convert(String.class, value);
}
catch (TypeConversionException e)
{
throw new ConstraintException(RMConstraintMessageKeys.ERR_NON_STRING, value, e);
}
// check that the value is in the set of allowed values
if (isCaseSensitive())
{
if (!getAllowedValues().contains(valueStr))
{
throw new ConstraintException(RMConstraintMessageKeys.ERR_INVALID_VALUE, value);
}
}
else
{
if (!getAllowedValuesUpper().contains(valueStr.toUpperCase()))
{
throw new ConstraintException(RMConstraintMessageKeys.ERR_INVALID_VALUE, value);
}
}
}
开发者ID:Alfresco,项目名称:records-management-old,代码行数:30,代码来源:RMListOfValuesConstraint.java
示例13: getDocument
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
public void getDocument(NodeRef nodeRef)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException,
ConstraintException
{
// TODO Wrap with try for null
String resourceID = nodeService.getProperty(nodeRef, GoogleDocsModel.PROP_RESOURCE_ID).toString();
getDocument(nodeRef, resourceID);
}
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:13,代码来源:GoogleDocsServiceImpl.java
示例14: getSpreadSheet
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
public void getSpreadSheet(NodeRef nodeRef)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException,
ConstraintException
{
// TODO Wrap with try for null
String resourceID = nodeService.getProperty(nodeRef, GoogleDocsModel.PROP_RESOURCE_ID).toString();
getSpreadSheet(nodeRef, resourceID);
}
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:13,代码来源:GoogleDocsServiceImpl.java
示例15: getPresentation
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
public void getPresentation(NodeRef nodeRef)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException,
ConstraintException
{
// TODO Wrap with try for null
String resourceID = nodeService.getProperty(nodeRef, GoogleDocsModel.PROP_RESOURCE_ID).toString();
getPresentation(nodeRef, resourceID);
}
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:13,代码来源:GoogleDocsServiceImpl.java
示例16: getDocument
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
/**
* Retrieve the Google Doc Document associated to this node from Google Docs into the repository
*
* @param nodeRef
*/
@Auditable(parameters = { "nodeRef" })
public void getDocument(NodeRef nodeRef)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException,
ConstraintException;
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:13,代码来源:GoogleDocsService.java
示例17: getSpreadSheet
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
/**
* Retrieve the Google Doc Spreadsheet associated to this node from Google Docs into the repository
*
* @param nodeRef
*/
@Auditable(parameters = { "nodeRef" })
public void getSpreadSheet(NodeRef nodeRef)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException,
ConstraintException;
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:13,代码来源:GoogleDocsService.java
示例18: getPresentation
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
/**
* Retrieve the Google Doc Presentation associated to this node from Google Docs into the repository
*
* @param nodeRef
*/
@Auditable(parameters = { "nodeRef" })
public void getPresentation(NodeRef nodeRef)
throws GoogleDocsAuthenticationException,
GoogleDocsServiceException,
GoogleDocsRefreshTokenException,
IOException,
ConstraintException;
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:13,代码来源:GoogleDocsService.java
示例19: isMetadataValid
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
private boolean isMetadataValid(ImportableItem importableItem)
{
if (!importableItem.getHeadRevision().metadataFileExists())
{
return true;
}
if (metadataLoader != null)
{
MetadataLoader.Metadata result = new MetadataLoader.Metadata();
metadataLoader.loadMetadata(importableItem.getHeadRevision(), result);
Map<QName, Serializable> metadataProperties = result.getProperties();
for (QName propertyName : metadataProperties.keySet())
{
PropertyDefinition propDef = dictionaryService.getProperty(propertyName);
if (propDef != null)
{
for (ConstraintDefinition constraintDef : propDef.getConstraints())
{
Constraint constraint = constraintDef.getConstraint();
if (constraint != null)
{
try
{
constraint.evaluate(metadataProperties.get(propertyName));
}
catch (ConstraintException e)
{
if (log.isWarnEnabled())
{
log.warn("Skipping file '" + FileUtils.getFileName(importableItem.getHeadRevision().getContentFile())
+"' with invalid metadata: '" + FileUtils.getFileName(importableItem.getHeadRevision().getMetadataFile()) + "'.", e);
}
return false;
}
}
}
}
}
}
return true;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:45,代码来源:DirectoryAnalyserImpl.java
示例20: setDefaultTaskProperties
import org.alfresco.service.cmr.dictionary.ConstraintException; //导入依赖的package包/类
/**
* Sets Default Properties of Task
*
* @param task
* task instance
*/
public void setDefaultTaskProperties(DelegateTask task)
{
TypeDefinition typeDefinition = typeManager.getFullTaskDefinition(task);
// Only local task properties should be set to default value
Map<QName, Serializable> existingValues = getTaskProperties(task, typeDefinition, true);
Map<QName, Serializable> defaultValues = new HashMap<QName, Serializable>();
Map<QName, PropertyDefinition> propertyDefs = typeDefinition.getProperties();
// for each property, determine if it has a default value
for (Map.Entry<QName, PropertyDefinition> entry : propertyDefs.entrySet())
{
QName key = entry.getKey();
String defaultValue = entry.getValue().getDefaultValue();
if (defaultValue != null && existingValues.get(key) == null)
{
defaultValues.put(key, defaultValue);
}
}
// Special case for property priorities
PropertyDefinition priorDef = propertyDefs.get(WorkflowModel.PROP_PRIORITY);
Serializable existingValue = existingValues.get(WorkflowModel.PROP_PRIORITY);
try
{
if(priorDef != null) {
for (ConstraintDefinition constraintDef : priorDef.getConstraints())
{
constraintDef.getConstraint().evaluate(existingValue);
}
}
}
catch (ConstraintException ce)
{
if(priorDef != null) {
Integer defaultVal = Integer.valueOf(priorDef.getDefaultValue());
if (logger.isDebugEnabled())
{
logger.debug("Task priority value ("+existingValue+") was invalid so it was set to the default value of "+defaultVal+". Task:"+task.getName());
}
defaultValues.put(WorkflowModel.PROP_PRIORITY, defaultVal);
}
}
// Special case for task description default value
String description = (String) existingValues.get(WorkflowModel.PROP_DESCRIPTION);
if (description == null || description.length() == 0)
{
//Try the localised task description first
String processDefinitionKey = ((ProcessDefinition) ((TaskEntity)task).getExecution().getProcessDefinition()).getKey();
description = factory.getTaskDescription(typeDefinition, factory.buildGlobalId(processDefinitionKey), null, task.getTaskDefinitionKey());
if (description != null && description.length() > 0) {
defaultValues.put(WorkflowModel.PROP_DESCRIPTION, description);
} else {
String descriptionKey = factory.mapQNameToName(WorkflowModel.PROP_WORKFLOW_DESCRIPTION);
description = (String) task.getExecution().getVariable(descriptionKey);
if (description != null && description.length() > 0) {
defaultValues.put(WorkflowModel.PROP_DESCRIPTION, description);
} else {
defaultValues.put(WorkflowModel.PROP_DESCRIPTION, task.getName());
}
}
}
// Assign the default values to the task
if (defaultValues.size() > 0)
{
setTaskProperties(task, defaultValues);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:78,代码来源:ActivitiPropertyConverter.java
注:本文中的org.alfresco.service.cmr.dictionary.ConstraintException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论