本文整理匯總了Java中org.alfresco.service.cmr.dictionary.CustomModelException類的典型用法代碼示例。如果您正苦於以下問題:Java CustomModelException類的具體用法?Java CustomModelException怎麽用?Java CustomModelException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CustomModelException類屬於org.alfresco.service.cmr.dictionary包,在下文中一共展示了CustomModelException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getModelNodeRef
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
@Override
public NodeRef getModelNodeRef(String modelName)
{
ParameterCheck.mandatoryString("modelName", modelName);
StringBuilder builder = new StringBuilder(120);
builder.append(repoModelsLocation.getPath()).append("//.[@cm:name='").append(modelName).append("' and ")
.append(RepoAdminServiceImpl.defaultSubtypeOfDictionaryModel).append(']');
List<NodeRef> nodeRefs = searchService.selectNodes(getRootNode(), builder.toString(), null, namespaceDAO, false);
if (nodeRefs.size() == 0)
{
return null;
}
else if (nodeRefs.size() > 1)
{
// unexpected: should not find multiple nodes with same name
throw new CustomModelException(MSG_MULTIPLE_MODELS, new Object[] { modelName });
}
return nodeRefs.get(0);
}
示例2: validatePropsDefaultValues
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
/**
* Validates the properties' non-null default values against the defined property constraints.
*
* @param compiledModel the compiled model
* @throws CustomModelException.CustomModelConstraintException if there is constraint evaluation
* exception
*/
private void validatePropsDefaultValues(CompiledModel compiledModel)
{
for (PropertyDefinition propertyDef : compiledModel.getProperties())
{
if (propertyDef.getDefaultValue() != null && propertyDef.getConstraints().size() > 0)
{
for (ConstraintDefinition constraintDef : propertyDef.getConstraints())
{
Constraint constraint = constraintDef.getConstraint();
try
{
constraint.evaluate(propertyDef.getDefaultValue());
}
catch (AlfrescoRuntimeException ex)
{
String message = getRootCauseMsg(ex, false, "cmm.service.constraint.default_prop_value_err");
throw new CustomModelException.CustomModelConstraintException(message);
}
}
}
}
}
示例3: validateTypeAspectDependency
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
private void validateTypeAspectDependency(Collection<? extends ClassDefinition> parentDefs, Collection<? extends ClassDefinition> childDefs)
{
for (ClassDefinition parentClassDef : parentDefs)
{
for (ClassDefinition childClassDef : childDefs)
{
if (parentClassDef.getName().equals(childClassDef.getParentName()))
{
Object[] msgParams = new Object[] { parentClassDef.getName().toPrefixString(),
childClassDef.getName().toPrefixString(),
childClassDef.getModel().getName().getLocalName() };
if (parentClassDef instanceof TypeDefinition)
{
throw new CustomModelException.CustomModelConstraintException(MSG_FAILED_DEACTIVATION_TYPE_DEPENDENCY, msgParams);
}
else
{
throw new CustomModelException.CustomModelConstraintException(MSG_FAILED_DEACTIVATION_ASPECT_DEPENDENCY, msgParams);
}
}
}
}
}
示例4: deleteCustomModel
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
@Override
public void deleteCustomModel(String modelName)
{
NodeRef nodeRef = getModelNodeRef(modelName);
if (nodeRef == null)
{
throw new CustomModelException.ModelDoesNotExistException(MSG_MODEL_NOT_EXISTS, new Object[] { modelName });
}
final boolean isActive = Boolean.TRUE.equals(nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_ACTIVE));
if (isActive)
{
throw new CustomModelException.ActiveModelConstraintException(MSG_UNABLE_DELETE_ACTIVE_MODEL);
}
try
{
repoAdminService.undeployModel(modelName);
}
catch (Exception ex)
{
throw new CustomModelException(MSG_UNABLE_MODEL_DELETE, new Object[] { modelName }, ex);
}
}
示例5: getModelNamespaceUriPrefix
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
private Pair<String, String> getModelNamespaceUriPrefix(M2Model model)
{
ParameterCheck.mandatory("model", model);
List<M2Namespace> namespaces = model.getNamespaces();
if (namespaces.isEmpty())
{
throw new CustomModelException.InvalidNamespaceException(MSG_NAMESPACE_NOT_EXISTS, new Object[] { model.getName() });
}
if (namespaces.size() > 1)
{
throw new CustomModelException.InvalidNamespaceException(MSG_NAMESPACE_MANY_EXIST, new Object[] { model.getName() });
}
M2Namespace ns = namespaces.iterator().next();
return new Pair<>(ns.getUri(), ns.getPrefix());
}
示例6: getCustomModelImpl
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
private CustomModelDefinition getCustomModelImpl(String modelName)
{
if(modelName == null)
{
throw new InvalidArgumentException(MODEL_NAME_NULL_ERR);
}
CustomModelDefinition model = null;
try
{
model = customModelService.getCustomModel(modelName);
}
catch (CustomModelException ex)
{
throw new EntityNotFoundException(modelName);
}
if (model == null)
{
throw new EntityNotFoundException(modelName);
}
return model;
}
示例7: doInTransaction
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
/**
* A helper method to run a unit of work in a transaction.
*
* @param errMsgId message id for the new wrapper exception ({@link CustomModelException})
* when an exception occurs
* @param requiresNewTx <tt>true</tt> to force a new transaction or
* <tt>false</tt> to partake in any existing transaction
* @param cb The callback containing the unit of work
* @return Returns the result of the unit of work
*/
private <R> R doInTransaction(String errMsgId, boolean requiresNewTx, RetryingTransactionCallback<R> cb)
{
try
{
return retryingTransactionHelper.doInTransaction(cb, false, requiresNewTx);
}
catch (Exception ex)
{
AlfrescoRuntimeException alf = null;
if (ex instanceof AlfrescoRuntimeException)
{
alf = (AlfrescoRuntimeException) ex;
}
else
{
alf = AlfrescoRuntimeException.create(ex, ex.getMessage());
}
Throwable cause = alf.getRootCause();
String message = getRootCauseMsg(cause, true, null);
throw new CustomModelException(errMsgId, new Object[] { message }, ex);
}
}
示例8: getCustomCompiledModel
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
/**
* Returns compiled custom model and whether the model is active or not as a {@code Pair} object
*
* @param modelName the name of the custom model to retrieve
* @return the {@code Pair<CompiledModel, Boolean>} (or null, if it doesn't exist)
*/
protected Pair<CompiledModel, Boolean> getCustomCompiledModel(String modelName)
{
ParameterCheck.mandatoryString("modelName", modelName);
final NodeRef modelNodeRef = getModelNodeRef(modelName);
if (modelNodeRef == null || !nodeService.exists(modelNodeRef))
{
return null;
}
M2Model model = null;
final boolean isActive = Boolean.TRUE.equals(nodeService.getProperty(modelNodeRef, ContentModel.PROP_MODEL_ACTIVE));
if (isActive)
{
QName modelQName = (QName) nodeService.getProperty(modelNodeRef, ContentModel.PROP_MODEL_NAME);
if (modelQName == null)
{
return null;
}
try
{
CompiledModel compiledModel = dictionaryDAO.getCompiledModel(modelQName);
model = compiledModel.getM2Model();
}
catch (Exception e)
{
throw new CustomModelException(MSG_RETRIEVE_MODEL, new Object[] { modelName }, e);
}
}
else
{
model = getM2Model(modelNodeRef);
}
Pair<CompiledModel, Boolean> result = (model == null) ? null : new Pair<>(compileModel(model), isActive);
return result;
}
示例9: createCustomModel
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
@Override
public CustomModelDefinition createCustomModel(M2Model m2Model, boolean activate)
{
ParameterCheck.mandatory("m2Model", m2Model);
String modelName = m2Model.getName();
int colonIndex = modelName.indexOf(QName.NAMESPACE_PREFIX);
final String modelFileName = (colonIndex == -1) ? modelName : modelName.substring(colonIndex + 1);
if (isModelExists(modelFileName))
{
throw new CustomModelException.ModelExistsException(MSG_NAME_ALREADY_IN_USE, new Object[] { modelFileName });
}
// Validate the model namespace URI
validateModelNamespaceUri(getModelNamespaceUriPrefix(m2Model).getFirst());
// Validate the model namespace prefix
validateModelNamespacePrefix(getModelNamespaceUriPrefix(m2Model).getSecond());
// Return the created model definition
CompiledModel compiledModel = createUpdateModel(modelFileName, m2Model, activate, MSG_CREATE_MODEL_ERR, false);
CustomModelDefinition modelDef = new CustomModelDefinitionImpl(compiledModel, activate, dictionaryService);
if (logger.isDebugEnabled())
{
logger.debug(modelFileName + " model has been created.");
}
return modelDef;
}
示例10: activateCustomModel
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
@Override
public void activateCustomModel(String modelName)
{
try
{
repoAdminService.activateModel(modelName);
}
catch (Exception ex)
{
throw new CustomModelException(MSG_UNABLE_MODEL_ACTIVATE, new Object[] { modelName }, ex);
}
}
示例11: deactivateCustomModel
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
@Override
public void deactivateCustomModel(final String modelName)
{
CustomModelDefinition customModelDefinition = getCustomModel(modelName);
if (customModelDefinition == null)
{
throw new CustomModelException.ModelDoesNotExistException(MSG_MODEL_NOT_EXISTS, new Object[] { modelName });
}
Collection<TypeDefinition> modelTypes = customModelDefinition.getTypeDefinitions();
Collection<AspectDefinition> modelAspects = customModelDefinition.getAspectDefinitions();
for (CompiledModel cm : getAllCustomM2Models(false))
{
// Ignore type/aspect dependency check within the model itself
if (!customModelDefinition.getName().equals(cm.getModelDefinition().getName()))
{
// Check if the type of the model being deactivated is the parent of another model's type
validateTypeAspectDependency(modelTypes, cm.getTypes());
// Check if the aspect of the model being deactivated is the parent of another model's aspect
validateTypeAspectDependency(modelAspects, cm.getAspects());
}
}
// requiresNewTx = true, in order to catch any exception thrown within
// "DictionaryModelType$DictionaryModelTypeTransactionListener" model validation.
doInTransaction(MSG_UNABLE_MODEL_DEACTIVATE, true, new RetryingTransactionCallback<Void>()
{
public Void execute() throws Exception
{
repoAdminService.deactivateModel(modelName);
return null;
}
});
}
示例12: validateModelNamespaceUri
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
private void validateModelNamespaceUri(String uri)
{
if (isNamespaceUriExists(uri))
{
throw new CustomModelException.NamespaceConstraintException(MSG_NAMESPACE_URI_ALREADY_IN_USE, new Object[] { uri });
}
}
示例13: validateModelNamespacePrefix
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
private void validateModelNamespacePrefix(String prefix)
{
if (isNamespacePrefixExists(prefix))
{
throw new CustomModelException.NamespaceConstraintException(MSG_NAMESPACE_PREFIX_ALREADY_IN_USE, new Object[] { prefix });
}
}
示例14: getShareExtModule
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
/**
* Gets Share persisted-extension nodeRef
*/
protected NodeRef getShareExtModule()
{
List<NodeRef> results = searchService.selectNodes(getRootNode(), this.shareExtModulePath, null, this.namespaceDAO, false,
SearchService.LANGUAGE_XPATH);
if (results.isEmpty())
{
throw new CustomModelException("cmm.service.download.share_ext_file_not_found");
}
return results.get(0);
}
示例15: compileModel
import org.alfresco.service.cmr.dictionary.CustomModelException; //導入依賴的package包/類
@Override
public CompiledModel compileModel(M2Model m2Model)
{
try
{
// Validate model dependencies, constraints and etc. before creating a node
return m2Model.compile(dictionaryDAO, namespaceDAO, true);
}
catch (Exception ex)
{
AlfrescoRuntimeException alf = null;
if (ex instanceof AlfrescoRuntimeException)
{
alf = (AlfrescoRuntimeException) ex;
}
else
{
alf = AlfrescoRuntimeException.create(ex, ex.getMessage());
}
Throwable cause = alf.getRootCause();
String message = null;
if (cause instanceof DuplicateDefinitionException)
{
message = getRootCauseMsg(cause, false, MSG_INVALID_MODEL);
throw new CustomModelException.CustomModelConstraintException(message);
}
else
{
message = getRootCauseMsg(cause, true, null);
throw new CustomModelException.InvalidCustomModelException(MSG_INVALID_MODEL, new Object[] { message }, ex);
}
}
}