赞赏:
首先,我要感谢你对这个问题的关心,
概述:
该问题在内置功能和JAVA代码中进行了测试,结果相同一旦露天服务器关闭并重新启动,节点将不会显示,除非我转到公司主文件夹。
问题:
我有了一个新的内容模型,新的对话框。主要内容模型是从cm:content扩展而来的组织模型,具有两个属性,一个用于组织名称,另一个用于描述组织。
在管理控制台中,我单击一个名为创建组织的新链接,创建组织对话框将被正确调用,一旦我填写数据并单击创建/完成按钮,组织将被正确创建。
案例1:
现在,所有的东西都被正确地传递了,但一旦我关闭了alfresco并再次启动它,一旦我直接进入节点浏览器而没有传递"公司主页"文件夹,节点浏览器将无法看到我的新节点。
案例2:
现在,所有的事情都通过了,但一旦我关闭了alfresco并重新启动它,一旦我进入公司主文件夹并返回到节点浏览器,创建的节点就会显示出来。
技术细节
我的内容模型:
<description>Security Content Model</description>
<author>MOHAMMED AMR</author>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
<import uri="http://www.alfresco.org/model/user/1.0" prefix="usr"/>
</imports>
<namespaces>
<namespace uri="www.ds.alfresco.security.extension.com" prefix="sec" />
</namespaces>
<types>
<type name="sec:organizationSequence">
<title>Organization Sequence</title>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>sec:sequencable</aspect>
</mandatory-aspects>
</type>
<type name="sec:positionSequence">
<title>Position Sequence</title>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>sec:sequencable</aspect>
</mandatory-aspects>
</type>
<type name="sec:position">
<title>Position</title>
<parent>cm:content</parent>
<properties>
<property name="sec:positionId">
<title>Position ID</title>
<type>d:int</type>
</property>
<property name="sec:positionName">
<title>Position Name</title>
<type>d:text</type>
</property>
<property name="sec:positionDescription">
<title>Position Description</title>
<type>d:text</type>
</property>
</properties>
<associations>
<child-association name="sec:suborindatesPositions">
<source>
<mandatory>true</mandatory>
<many>false</many>
</source>
<target>
<class>sec:position</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
<duplicate>false</duplicate>
<propagateTimestamps>true</propagateTimestamps>
</child-association>
</associations>
</type>
<type name="sec:organization">
<title>Organization</title>
<parent>cm:content</parent>
<properties>
<property name="sec:organizationId">
<title>Organization ID</title>
<type>d:int</type>
</property>
<property name="sec:organizationName">
<title>Organization Name</title>
<type>d:text</type>
</property>
<property name="sec:organizationDescription">
<title>Organization Description</title>
<type>d:text</type>
</property>
<property name="sec:rootPosition">
<title>Root Position</title>
<type>d:noderef</type>
</property>
</properties>
</type>
</types>
<aspects>
<aspect name="sec:sequencable">
<title>Capable To Have a Sequence</title>
<parent>cm:content</parent>
<properties>
<property name="sec:sequenceId">
<title>Sequence</title>
<type>d:int</type>
</property>
<property name="sec:sequenceName">
<title>Sequence Name</title>
<type>d:text</type>
</property>
</properties>
</aspect>
</aspects>
我的Java代码:
我的java代码将分两步创建组织
第一步将创建没有任何元数据的组织节点,以便用户有机会从对话框中输入组织的元数据。
第一步:
public final RetryingTransactionCallback<String> CreateOrganizationCallback
= new RetryingTransactionCallback<String>() {
public String execute() throws Throwable {
// ACQUIRE THE FOLDER NODE REF
Node organizationsFolder = new Node(NodeUtil
.acquireOrganizationsFolder(searchService));
// CURRENT ORGANIZATION CREATION
currentOrganization = new Node(
nodeService.createNode(
organizationsFolder.getNodeRef(),
ContentModel.ASSOC_CONTAINS,
QName.createQName(
Constants.DIGITAL_SERIES_SECURITY_MODEL_NAMEPSACE_PREFIX_STRING,
Constants.TYPE_SEC_ORGANIZATION_STRING,namespacePrefixResolver),
Constants.SecurityModelQNames.TYPE_SEC_ORGANIZATION,
new HashMap<QName,Serializable>()).getChildRef());
return "";
}
};
第二步:
public final RetryingTransactionCallback<String> CreateOrganizationCallback = new RetryingTransactionCallback<String>() {
public String execute() throws Throwable {
// PREPARE ORGANIZATION SEQUENCE ID
Node organizationSeq = new Node(SequenceUtil.prepareSequence(
SequenceUtil.ORGANIZATION_SEQUENCE_NODE_NAME_STRING,
nodeService, searchService));
// LOCK ORGANIZATION SEQUENCE
if(!organizationSeq.isLocked()){
lockService.lock(organizationSeq.getNodeRef(), LockType.NODE_LOCK);
// GET THE NEXT SEQUENCE
SequenceUtil.addCurrentSequence(organizationSeq.getNodeRef(), nodeService);
}
// PREPARE ORGANIZATION PROPERTIES
Map<QName, Serializable> orgProps = new HashMap<QName, Serializable>();
// UPDATE ORGANIZATION SEQUENCE ID
orgProps.put(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_ID,
SequenceUtil.getCurrentSequence(
organizationSeq.getNodeRef(), nodeService));
// UPDATE ORGANIZATION/CONTENT NAME PROPERTY
orgProps.put(ContentModel.PROP_NAME,
NodeUtil.extractNodeProperty(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_NAME,
currentOrganization).toString() +
"_"+orgProps.get(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_ID));
// UPDATE ORGANIZATION NAME PROPERTY
orgProps.put(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_NAME,
NodeUtil.extractNodeProperty(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_NAME,
currentOrganization).toString());
// UPDATE ORGANIZATION DESCRIPTION
orgProps.put(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_DESCRIPTION,
NodeUtil.extractNodeProperty(Constants.SecurityModelQNames.PROP_SEC_ORGANIZATION_ORGANIZATION_DESCRIPTION,
currentOrganization).toString());
// UPDATE THE PROPERTIES TO AN ORGANIZATION NODE
nodeService.setProperties(currentOrganization.getNodeRef(), orgProps);
// UNLOCK
lockService.unlock(organizationSeq.getNodeRef());
return TO_ADMIN_CONSOLE_PAGE;
}
};
注意:如果没有JAVA代码,当您使用alfrescoatr中的内置功能从自定义模型创建内容时,行为将是相同的
注意:不要在内置模型中测试问题,因为行为将不再显示。
我在等你的答复。
感谢您的帮助,非常感谢您的回复。
穆罕默德·阿姆尔高级系统开发人员Digital Series Co.
我认为您正在创建一个没有元数据的节点。这就是为什么你不能搜索它。
尝试以下操作:
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
props.put(ContentModel.PROP_NAME, "Testfile");
currentOrganization = new Node(
nodeService.createNode(
organizationsFolder.getNodeRef(),
ContentModel.ASSOC_CONTAINS,
QName.createQName(Constants.DIGITAL_SERIES_SECURITY_MODEL_NAMEPSACE_PREFIX_STRING, Constants.TYPE_SEC_ORGANIZATION_STRING,namespacePrefixResolver),
Constants.SecurityModelQNames.TYPE_SEC_ORGANIZATION,
props);
重要的部分是将cm:name元数据提供给节点并提供子名称。
这是我创建节点的代码:
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
props.put(ContentModel.PROP_NAME, logFileName);
ChildAssociationRef logRef = getNodeService().createNode(downloadFolder, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, logFileName), ContentModel.TYPE_CONTENT, props);