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


Java CustomModelException類代碼示例

本文整理匯總了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);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:24,代碼來源:CustomModelServiceImpl.java

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

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

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

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

示例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;
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:25,代碼來源:CustomModelsImpl.java

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

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

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

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

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

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

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

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

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


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