當前位置: 首頁>>代碼示例>>Java>>正文


Java CustomModelException.ActiveModelConstraintException方法代碼示例

本文整理匯總了Java中org.alfresco.service.cmr.dictionary.CustomModelException.ActiveModelConstraintException方法的典型用法代碼示例。如果您正苦於以下問題:Java CustomModelException.ActiveModelConstraintException方法的具體用法?Java CustomModelException.ActiveModelConstraintException怎麽用?Java CustomModelException.ActiveModelConstraintException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.alfresco.service.cmr.dictionary.CustomModelException的用法示例。


在下文中一共展示了CustomModelException.ActiveModelConstraintException方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:24,代碼來源:CustomModelServiceImpl.java

示例2: updateCustomModel

import org.alfresco.service.cmr.dictionary.CustomModelException; //導入方法依賴的package包/類
@Override
public CustomModelDefinition updateCustomModel(String modelFileName, M2Model m2Model, boolean activate)
{
    ParameterCheck.mandatory("m2Model", m2Model);

    final NodeRef existingModelNodeRef = getModelNodeRef(modelFileName);
    if (existingModelNodeRef == null)
    {
        throw new CustomModelException.ModelDoesNotExistException(MSG_MODEL_NOT_EXISTS, new Object[] { modelFileName });
    }
    // Existing model property and namespace uri-prefix pair
    final boolean isActive = Boolean.TRUE.equals(nodeService.getProperty(existingModelNodeRef, ContentModel.PROP_MODEL_ACTIVE));
    final M2Model existingModel = getM2Model(existingModelNodeRef);
    final Pair<String, String> existingNamespacePair = getModelNamespaceUriPrefix(existingModel);
    // New model namespace uri-prefix pair
    final Pair<String, String> newNamespacePair = getModelNamespaceUriPrefix(m2Model);

    if (isActive && !(existingNamespacePair.equals(newNamespacePair)))
    {
        throw new CustomModelException.ActiveModelConstraintException(MSG_NAMESPACE_ACTIVE_MODEL);
    }

    // if the prefix has changed, then check the new prefix is not in use.
    if (!existingNamespacePair.getSecond().equals(newNamespacePair.getSecond()))
    {
        validateModelNamespacePrefix(newNamespacePair.getSecond());
    }

    // if the URI has changed, then check the new URI is not in use.
    if (!existingNamespacePair.getFirst().equals(newNamespacePair.getFirst()))
    {
        validateModelNamespaceUri(newNamespacePair.getFirst());
    }

    /*
     * We set the requiresNewTx = true, in order to catch any exception
     * thrown within the low level content model management.
     * For example, deleting a property of an active model, where the
     * property has been applied to a node will cause the
     * ModelValidatorImpl to throw an exception.
     * Without starting a new TX, we can't catch that exception.
     */
    CompiledModel compiledModel = createUpdateModel(modelFileName, m2Model, activate, MSG_UPDATE_MODEL_ERR, true);
    CustomModelDefinition modelDef = new CustomModelDefinitionImpl(compiledModel, activate, dictionaryService);

    if (logger.isDebugEnabled())
    {
        logger.debug(modelFileName + " model has been updated.");
    }
    return modelDef;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:52,代碼來源:CustomModelServiceImpl.java


注:本文中的org.alfresco.service.cmr.dictionary.CustomModelException.ActiveModelConstraintException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。