当前位置: 首页>>代码示例>>Java>>正文


Java AlfrescoRuntimeException.create方法代码示例

本文整理汇总了Java中org.alfresco.error.AlfrescoRuntimeException.create方法的典型用法代码示例。如果您正苦于以下问题:Java AlfrescoRuntimeException.create方法的具体用法?Java AlfrescoRuntimeException.create怎么用?Java AlfrescoRuntimeException.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.error.AlfrescoRuntimeException的用法示例。


在下文中一共展示了AlfrescoRuntimeException.create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAlias

import org.alfresco.error.AlfrescoRuntimeException; //导入方法依赖的package包/类
/**
 * Set the email alias for the specified node. 
 * 
 * If the rule is broken, AlfrescoRuntimeException will be thrown.
 * 
 * @param nodeRef Reference to target node
 * @param alias Alias that we want to set to the target node
 * @exception AlfrescoRuntimeException if the <b>alias</b> property is duplicated by another node.
 */
public void addAlias(NodeRef nodeRef, String alias)
{
    if(logger.isDebugEnabled())
    {
        logger.debug("add email alias nodeRef:" + nodeRef + ", alias:" + alias);
    }
    // first try to see if the new alias is in use elsewhere?   
    try
    {
        attributeService.createAttribute(nodeRef, ALIASABLE_ATTRIBUTE_KEY_1, ALIASABLE_ATTRIBUTE_KEY_2, normaliseAlias(alias));
    }
    catch (DuplicateAttributeException de)
    {
        throw AlfrescoRuntimeException.create(ERROR_MSG_DUPLICATE_ALIAS, normaliseAlias(alias));
    }
    
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:AliasableAspect.java

示例2: registerComponent

import org.alfresco.error.AlfrescoRuntimeException; //导入方法依赖的package包/类
/**
 * Add a managed module component to the registry of components.  These will be controlled
 * by the {@link #startModules()} method.
 * 
 * @param component a module component to be executed
 */
public synchronized void registerComponent(ModuleComponent component)
{
    String moduleId = component.getModuleId();
    String name = component.getName();
    // Get the map of components for the module
    Map<String, ModuleComponent> componentsByName = componentsByNameByModule.get(moduleId);
    if (componentsByName == null)
    {
        componentsByName = new HashMap<String, ModuleComponent>(11);
        componentsByNameByModule.put(moduleId, componentsByName);
    }
    // Check if the component has already been registered
    if (componentsByName.containsKey(name))
    {
        throw AlfrescoRuntimeException.create(ERR_COMPONENT_ALREADY_REGISTERED, name, moduleId);
    }
    // Add it
    componentsByName.put(name, component);
    // Done
    if (logger.isDebugEnabled())
    {
        logger.debug("Registered component: " + component);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:ModuleComponentHelper.java

示例3: checkTxnState

import org.alfresco.error.AlfrescoRuntimeException; //导入方法依赖的package包/类
/**
 * Checks that the 'System' user is active in a read-write txn.
 */
private final void checkTxnState(TxnReadState txnStateNeeded)
{
    switch (txnStateNeeded)
    {
        case TXN_READ_WRITE:
            if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE)
            {
                throw AlfrescoRuntimeException.create("system.usage.err.no_txn_readwrite");
            }
            break;
        case TXN_READ_ONLY:
            if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_NONE)
            {
                throw AlfrescoRuntimeException.create("system.usage.err.no_txn");
            }
            break;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:RepoUsageComponentImpl.java

示例4: checkForOrphanComponents

import org.alfresco.error.AlfrescoRuntimeException; //导入方法依赖的package包/类
/**
 * Checks that all components have been executed or considered for execution.
 * @param executedComponents Set<ModuleComponent>
 */
private void checkForOrphanComponents(Set<ModuleComponent> executedComponents)
{
    Set<ModuleComponent> missedComponents = new HashSet<ModuleComponent>(executedComponents);
    
    // Iterate over each module registered by components
    for (Map.Entry<String, Map<String, ModuleComponent>> entry : componentsByNameByModule.entrySet())
    {
        String moduleId = entry.getKey();
        Map<String, ModuleComponent> componentsByName = entry.getValue();
        // Iterate over each component registered against the module ID
        for (Map.Entry<String, ModuleComponent> entryInner : componentsByName.entrySet())
        {
            String componentName = entryInner.getKey();
            ModuleComponent component = entryInner.getValue();
            // Check if it has been executed
            if (executedComponents.contains(component))
            {
                // It was executed, so remove it from the missed components set
                missedComponents.remove(component);
            }
            else
            {
                String msg = I18NUtil.getMessage(
                        ERR_COMPONENT_IN_MISSING_MODULE,
                        componentName, moduleId);
                logger.error(msg);
            }
        }
    }
    // Dump if there were orphans
    if (missedComponents.size() > 0)
    {
        throw AlfrescoRuntimeException.create(ERR_ORPHANED_COMPONENTS, missedComponents.size());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:40,代码来源:ModuleComponentHelper.java

示例5: execute

import org.alfresco.error.AlfrescoRuntimeException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see #executeInternal() the abstract method to be implemented by subclasses
 */
public final synchronized void execute()
{
    // ensure that this has not been executed already
	String tenantDomain = tenantAdminService.getCurrentUserDomain();
	if (! executed.containsKey(tenantDomain))
	{
		executed.put(tenantDomain, false);
	}
	
    if (executed.get(tenantDomain))
    {
        throw AlfrescoRuntimeException.create(ERR_ALREADY_EXECUTED, moduleId, name);
    }
    // Ensure properties have been set
    checkProperties();
    // Execute
    try
    {
        executeInternal();
    }
    catch (Throwable e)
    {
        throw AlfrescoRuntimeException.create(e, ERR_EXECUTION_FAILED, name, e.getMessage());
    }
    finally
    {
        // There are no second chances
    	executed.put(tenantDomain, true);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:36,代码来源:AbstractModuleComponent.java

示例6: executeScriptUrl

import org.alfresco.error.AlfrescoRuntimeException; //导入方法依赖的package包/类
private void executeScriptUrl(Configuration cfg, Connection connection, String scriptUrl) throws Exception
{
    Dialect dialect = Dialect.getDialect(cfg.getProperties());
    String dialectStr = dialect.getClass().getSimpleName();
    InputStream scriptInputStream = getScriptInputStream(dialect.getClass(), scriptUrl);
    // check that it exists
    if (scriptInputStream == null)
    {
        throw AlfrescoRuntimeException.create(ERR_SCRIPT_NOT_FOUND, scriptUrl);
    }
    // write the script to a temp location for future and failure reference
    File tempFile = null;
    try
    {
        tempFile = TempFileProvider.createTempFile("AlfrescoSchema-" + dialectStr + "-Update-", ".sql");
        ContentWriter writer = new FileContentWriter(tempFile);
        writer.putContent(scriptInputStream);
    }
    finally
    {
        try { scriptInputStream.close(); } catch (Throwable e) {}  // usually a duplicate close
    }
    // now execute it
    String dialectScriptUrl = scriptUrl.replaceAll(PLACEHOLDER_DIALECT, dialect.getClass().getName());
    // Replace the script placeholders
    executeScriptFile(cfg, connection, tempFile, dialectScriptUrl);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:ScriptExecutorImpl.java

示例7: beforeDeleteNode

import org.alfresco.error.AlfrescoRuntimeException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void beforeDeleteNode(NodeRef nodeRef)
{
    boolean workingCopy = nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY);
    NodeRef wcNodeRef = (NodeRef)AlfrescoTransactionSupport.getResource(KEY_WORKING_COPY);
    if ((wcNodeRef != null) && (wcNodeRef.equals(nodeRef)))
    {
        workingCopy = true;
    }
    
    boolean isVersionNode = nodeRef.getStoreRef().getIdentifier().equals(Version2Model.STORE_ID);
    
    // Ignore if the node is a working copy or version node
    if (! (workingCopy || isVersionNode))
    {
        QName modelName = (QName)this.nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_NAME);
        
        if (logger.isTraceEnabled())
        {
            logger.trace("beforeDeleteNode: nodeRef="+nodeRef+" validate model delete (modelName="+modelName+")");
        }
        
        if (modelName != null)
        {
            // Validate model delete against usages - content and/or workflows
            if (!modelValidator.canDeleteModel(modelName))
            {
                throw AlfrescoRuntimeException.create(MODEL_IN_USE, modelName);
            }

            Set<NodeRef> pendingModelDeletes = (Set<NodeRef>)AlfrescoTransactionSupport.getResource(KEY_PENDING_DELETE_MODELS);
            if (pendingModelDeletes == null)
            {
                //pendingModelDeletes = Collections.newSetFromMap(new ConcurrentHashMap()); // Java 6
                pendingModelDeletes = new CopyOnWriteArraySet<NodeRef>();
                AlfrescoTransactionSupport.bindResource(KEY_PENDING_DELETE_MODELS, pendingModelDeletes);
            }
            pendingModelDeletes.add(tenantService.getName(nodeRef));
            
            AlfrescoTransactionSupport.bindListener(this.transactionListener);
        }
    }
    else
    {
        if (logger.isTraceEnabled())
        {
            logger.trace("beforeDeleteNode: nodeRef="+nodeRef+ " ignored ("+(workingCopy ? " workingCopy " : "")+(isVersionNode ? " isVersionNode " : "")+") ["+AlfrescoTransactionSupport.getTransactionId()+"]");
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:51,代码来源:DictionaryModelType.java

示例8: checkSchemaPatchScripts

import org.alfresco.error.AlfrescoRuntimeException; //导入方法依赖的package包/类
/**
 * Check that the necessary scripts have been executed against the database
 */
private void checkSchemaPatchScripts(
        Configuration cfg,
        Connection connection,
        List<SchemaUpgradeScriptPatch> scriptPatches,
        boolean apply) throws Exception
{
    // first check if there have been any applied patches
    int appliedPatchCount = countAppliedPatches(cfg, connection);
    if (appliedPatchCount == 0)
    {
        // This is a new schema, so upgrade scripts are irrelevant
        // and patches will not have been applied yet
        return;
    }
    // Retrieve the first installed schema number
    int installedSchema = getInstalledSchemaNumber(connection);

    nextPatch:
    for (SchemaUpgradeScriptPatch patch : scriptPatches)
    {
        final String patchId = patch.getId();
        final String scriptUrl = patch.getScriptUrl();
        
        // Check if any of the alternative patches were executed
        List<Patch> alternatives = patch.getAlternatives();
        for (Patch alternativePatch : alternatives)
        {
            String alternativePatchId = alternativePatch.getId();
            boolean alternativeSucceeded = didPatchSucceed(connection, alternativePatchId, true);
            if (alternativeSucceeded)
            {
                continue nextPatch;
            }
        }

        // check if the script was successfully executed
        boolean wasSuccessfullyApplied = didPatchSucceed(connection, patchId, false);
        if (wasSuccessfullyApplied)
        {
            // Either the patch was executed before or the system was bootstrapped
            // with the patch bean present.
            continue;
        }
        else if (!patch.applies(installedSchema))
        {
            // Patch does not apply to the installed schema number
            continue;
        }
        else if (!apply)
        {
            // the script was not run and may not be run automatically
            throw AlfrescoRuntimeException.create(ERR_SCRIPT_NOT_RUN, scriptUrl);
        }
        // it wasn't run and it can be run now
        executeScriptUrl(cfg, connection, scriptUrl);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:61,代码来源:SchemaBootstrap.java


注:本文中的org.alfresco.error.AlfrescoRuntimeException.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。