alfresco自定义内容模型,使用自定义模型上传文件。
通过自定义内容模型,扩展内容属性,注入业务需要的相关属性。
1、定义内容模型文件
例如 StudentContentModel.xml
<?xml version="1.0" encoding="UTF-8"?>
<model name="yy:student" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<description>Student Content Model</description>
<author>yuyong</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"/>
</imports>
<namespaces>
//内容模型的命名空间
<namespace uri="yy.student.model" prefix="yy"/>
</namespaces>
<aspects>
//定义内容自定义属性
<aspect name="yy:studentAspect">
<title>The Student Content Model aspect</title>
<properties>
<property name="yy:name">
<type>d:text</type>
</property>
<property name="yy:age">
<type>d:int</type>
</property>
</properties>
</aspect>
</aspects>
</model>
2、修改custom-model-content.xml文件,引入定义的内容模型文件
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="custom.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/extension/StudentContentModel.xml</value>
</list>
</property>
</bean>
</beans>
3、修改web-client-config-custom.xml文件,添加客户端显示的内容模型属性
<alfresco-config>
<config evaluator="aspect-name" condition="yy:studentAspect">
<property-sheet>
<show-property name="yy:name"/>
<show-property name="yy:age"/>
</property-sheet>
</config>
<config evaluator="string-compare" condition="Action Wizards">
<aspects>
<aspect name="yy:studentAspect"/>
</aspects>
</config>
</alfresco-config>
将三个文件放入 alfresco\tomcat\shared\classes\alfresco\extension中
编程上传文件,使用自定义的内容模型,使用自定义的扩展属性
alfresco-webservice:
通过alfresco-webservice在company_home space下面的student的space中,根据自定义StudentContentModel内容模型上传文件,并且赋予自定义属性
startSession();
Store STORE = new Store(Constants.WORKSPACE_STORE,
"SpacesStore");
ParentReference companyHomeParent = new ParentReference(
STORE, null, "/app:company_home",
Constants.ASSOC_CONTAINS, null);
Reference space = new Reference(STORE, null, companyHomeParent.getPath()
+ "/cm:" + "student");
String docname ="upload.doc";
Reference document = null;
//内容模型的域
String domain="{yy.student.model}";
//内容模型属性集合
String aspect_name="articleAspect";
ParentReference parent = new ParentReference();
parent.setStore(STORE);
parent.setPath(space.getPath());
parent.setUuid(space.getUuid());
parent.setAssociationType(Constants.ASSOC_CONTAINS);
parent.setChildName(Constants.createQNameString(
Constants.NAMESPACE_CONTENT_MODEL, docname));
NamedValue[] properties = new NamedValue[] { Utils.createNamedValue(
Constants.PROP_NAME, docname) };
CMLCreate create = new CMLCreate("1", parent, null, null, null,
Constants.TYPE_CONTENT, properties);
NamedValue[] aspect_properties = new NamedValue[2];
aspect_properties[0] = Utils.createNamedValue(domain+"name", "yuyong");
aspect_properties[1] = Utils.createNamedValue(domain+"age", "23");
CMLAddAspect addaspect = new CMLAddAspect();
addaspect.setAspect(domain+aspect_name);
addaspect.setProperty(aspect_properties);
addaspect
.setWhere(new Predicate(new Reference[] { parent }, null, null));
addaspect.setWhere_id("1");
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
cml.setAddAspect(new CMLAddAspect[] { addaspect });
UpdateResult[] results = null;
try {
results = getRepositoryService().update(cml);
document = results[0].getDestination();
} catch (Exception e) {
System.err.println("Can not create the document");
throw e;
}
//以上是在student space下面定义一个项目的reference,并且根据内容模型的定义赋予自定义属性值。此时,此reference还没有文件内容。仅仅项目属性的赋值。
//以下是上面已经定义的项目中写入文件内容。格式需要正确,写入后,可以通过 alfresco web application查看到上传的文件
byte[] documentStream=getDocumentStream();
ContentFormat format = new ContentFormat("application/msword","UTF-8");
try {
WebServiceFactory.getContentService().write(document, Constants.PROP_CONTENT,
documentStream, format);
} catch (Exception e) {
System.err.println("Can not set the content of the document");
throw e;
}
endSession();
分享到:
相关推荐
露天 Alfresco ORM是一流的持久性框架,支持相关的Alfrresco内容模型和Java对象。 该框架是减少服务Alfresco API所需的... 通过使用注释将露天内容模型及其属性映射到Object。 动机 Alfresco内容模型很难理解并映射到O
ADAMO代表Alfresco DAta MOdel。 设置该应用程序是为了允许用户友好地创建Alfresco自定义模型。 ADAMO前端是使用Spring Surf开发的。
最后一个仅用于测试目的,使用包含的自定义表单控件的自定义模型。 因此,您只需要担心安装共享放大器。 包含自定义表单控件 包含 ,用于测试和指导目的,并引用存储库amp中包含的。 分级删除列表 相关的自定义窗体...
简单的第三方自定义页面模型旨在通过Surf扩展模块进行动态自定义,这意味着客户端(例如Alfresco Share)可以由第三方动态自定义,而无需编写任何代码。 模块化方法意味着第三方很容易提供全新的或扩展了Aikau基础的...
2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...
2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...
2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...
2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...
2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...
Java从网络取得文件 1个目标文件 简单 Java从压缩包中提取文件 1个目标文件 简单 Java存储与读取对象 1个目标文件 如题 Java调色板面板源代码 1个目标文件 摘要:Java源码,窗体界面,调色板 使用Java语言编写的一款...
Java从网络取得文件 1个目标文件 简单 Java从压缩包中提取文件 1个目标文件 简单 Java存储与读取对象 1个目标文件 如题 Java调色板面板源代码 1个目标文件 摘要:Java源码,窗体界面,调色板 使用Java语言编写的一款...
使用.ashx文件处理IHttpHandler实现发送文本及二进制数据的方法 制作一个简单的多页Tab功能 一完美的关于请求的目录不存在而需要url重写的解决方案! 在C#中实现MSN消息框的功能 XmlHttp实现无刷新三联动ListBox 鼠标...
2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...