问题描述
大多数教程都没有考虑到这一点,但是我想在很多情况下节点不能满足自定义方面的所有要求。
Most tutorials don't take this into account, but I suppose there are many occasions where a node doesn't meet all requirements for a custom aspect.
我发现发生这种情况的唯一方法是开发一个行为,然后在beforeAddAspect中抛出Alfresco运行时异常。
The only way I found for this to occur is to develop a behavior, and in beforeAddAspect throw an Alfresco runtime exception.
通过将before add方面分类注册为FIRST_EVENT来发生这种情况
Which is happening by registering a before add aspect categorically as FIRST_EVENT
this.beforeAddAspect = new JavaBehaviour(this, BEFORE_ADD_ASPECT, NotificationFrequency.FIRST_EVENT);
然后抛出错误本身:
@Override
public void beforeAddAspect(NodeRef nodeRef, QName aspectTypeQName) {
if(!hasRequirements())) {
throw AlfrescoRuntimeException.create("error.my.message", new Object[]{......});
}
}
我想知道我是否正在这样做正确,或者如果有其他解决方案不涉及引发错误。
I wonder if I am doing it right, or if there are any other solution which involves not throwing errors.
这种错误方法也有缺点,错误消息无法自定义,并且用户
This "error approach" has also a downside, the error message cannot be customized, and the user is getting a standard one.
基本上,如上所述,这是一个自定义方面,在开发时(目前)是一个标记方面。根据需要,让我提供一些关于该主题的细节:
Basically, as mentioned, this is a Custom Aspect, at time of development is a marker aspect (for the moment). As required, let me give few details about the subject:
- Aspect仅适用于内容类型,并且可以选择(希望如此)仅针对特定的模仿类型。
- 通过应用方面,在节点上启动了一些操作:标记,计算变量等。用户期望如果节点具有方面,则还会发生其他事情。
- 一切都发生在共享UI边界中,用户以经典方式应用方面,但是他在节点视图上也很少有快捷方式操作,它们可以执行相同的操作,应用/删除方面。唯一的区别是该操作会向用户提供自定义的反馈错误/成功。
我正在使用Alfresco 4.2f
I am using Alfresco 4.2f
推荐答案
关于错误消息。您可以在下面实现。
Regarding Error message.you can achieve that by below.
您可以从hasRequirements函数返回错误代码。根据错误代码或成功代码,您可以显示消息。
You can return error code from hasRequirements function.According to error code or success code you can display message.
您的方法是满足业务需求的最佳方法。
Your approach is the best approach for achieving your business requirement.You can achieve it using policy only.
希望这会有所帮助:)
这篇关于阻止在Alfresco Share中添加Aspect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!