`
猫不吃的鱼
  • 浏览: 158580 次
  • 性别: Icon_minigender_1
  • 来自: 芜湖市
社区版块
存档分类
最新评论

alfresco自定义内容模型,使用自定义模型上传文件。

阅读更多
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();
1
0
分享到:
评论
2 楼 猫不吃的鱼 2012-07-14  
liubang201010 写道
Alfresco一些参考资料:
http://www.innovatedigital.com/Alfresco

Alfresco技术论坛:
http://g.51cto.com/alfresco



谢谢分享 
1 楼 liubang201010 2012-07-13  
Alfresco一些参考资料:
http://www.innovatedigital.com/Alfresco

Alfresco技术论坛:
http://g.51cto.com/alfresco

相关推荐

    alfresco在5.0版本下实现自定义属性详细步骤

    综上所述,Alfresco 5.0版本中实现自定义属性涉及到内容模型的创建、注册、数据类型的定义、节点类型的创建、表单设计、工作流配置以及界面定制等多个环节。通过这些步骤,我们可以灵活地扩展Alfresco的功能,以适应...

    alfresco讲义

    - **内容模型**:内容模型是Alfresco中定义内容类型的基础,包括模型名称、模型命名空间、模型版本等信息。 - **元数据**:自定义内容类型可以通过添加元数据字段来增强其功能性,例如添加标题、描述、日期等字段。 ...

    Alfresco开发者指南

    它不仅提供了基础的文档管理功能,如文件存储、版本控制、搜索和检索等,还支持高级特性,包括工作流管理、内容审批、自定义表单和报表生成等。这些特性使得Alfresco成为企业和组织进行内容管理和协作的理想选择。 ...

    alfresco developer guide

    - 解释了 Alfresco 的扩展机制,包括如何使用 Java Web 应用程序文件和框架文件进行定制。 **打包和部署自定义功能**: - 描述了如何将自定义功能打包成独立的模块,并部署到生产环境中。 **调试技巧**: - 介绍...

    alfresco-mmt.jar.zip

    这些模块可以包含各种定制的业务逻辑、工作流程、内容模型和用户界面组件,以扩展或定制Alfresco的功能。Alfresco MMT的主要功能包括: 1. 安装模块:将新的模块添加到Alfresco实例中,以便利用其提供的新特性或...

    Alfresco Developer Guide

    1. **内容模型**:开发者可以通过定义自定义的内容模型来扩展Alfresco,这些模型定义了内容的结构、属性和行为。 2. **工作流**:Alfresco支持通过 Activiti 和 JBPM 实现的工作流引擎,允许开发者创建复杂的业务...

    Alfresco Developer Guide开发手册

    - **扩展Alfresco**:深入讲解了Alfresco的扩展机制,包括标准Java Web应用程序文件、框架文件等,并提供了包装和部署自定义功能的具体步骤。 - **调试技巧**:介绍了如何在Eclipse中进行调试,并讨论了日志配置等...

    Alfresco文档管理系统

    - 模型管理器用于创建和管理内容模型。 - 用户可以自定义类型和切面的属性,以适应特定的需求。 23. **使用模型**: - 内容模型定义了文档的结构和行为。 - 支持为不同类型的内容设置不同的属性和行为。 #### ...

    Alfresco.Share一书的源码

    2. **工作流程**:Alfresco Share支持自定义工作流程,使用Activiti作为工作流引擎。源码中包含了工作流模板和配置,有助于理解如何创建、启动和管理工作流程。 3. **社交特性**:Alfresco Share集成了博客、论坛、...

    Alfresco share简介

    3. **内容模型**:定义新的内容类型和元数据,以适应特定业务需求,例如项目管理、客户服务等场景。 4. **模板设计**:使用FreeMarker模板语言创建自定义的页面布局和样式,提升用户体验。 5. **工作流开发**:...

    alfresco cookbook+share+developer guide

    《Alfresco Developer Guide》是为开发者准备的详细教程,涵盖了Alfresco的开发环境搭建、自定义模块开发、工作流设计、API使用等内容。在这一部分,你可以学习到如何利用Java、Groovy或Spring框架来扩展Alfresco的...

    Alfresco2_1_Installation_Guide.

    常用的定制方法包括使用Share web scripts、自定义模型等。 ### 总结 Alfresco作为一款功能强大且灵活的内容管理系统,为企业提供了高效的内容管理和协作平台。通过上述步骤,用户可以顺利完成Alfresco的安装和...

    ACSCE-5X - Alfresco Content Services Certified Engineer认证考试题库.docx

    行为是Alfresco中用于添加自定义逻辑的功能,它可以被附加到内容模型实体上,比如节点类型(cmis:object)、内容(cm:content)、文件夹(cm:folder)等。因此,行为可以与多个内容模型实体关联。 以上知识点涵盖...

    alfresco文档

    Alfresco是一款开源的企业内容管理系统(ECM),它提供了丰富的功能来帮助用户管理文档、协作、流程等。对于开发者而言,了解Alfresco的核心架构和技术栈至关重要。本文档将详细介绍与Alfresco开发相关的各个方面。 ...

    alfresco web services

    Alfresco Web Services 是一套基于Java技术的企业级内容管理系统(Content Management System, CMS)的服务接口集合,旨在为开发者提供灵活且强大的方式来与Alfresco系统交互。通过这些服务,可以实现对文档管理、工作...

    Professional Alfresco,

    - **定义与背景**:首先介绍了Alfresco是什么,它是一个开源的企业内容管理系统,旨在帮助企业管理和组织数字内容。 - **功能特性**:概述了Alfresco的主要功能,包括文档管理、工作流程管理等。 - **应用场景**:...

    基于Java的实例源码-客户管理系统 Alfresco Content Management.zip

    这使得Alfresco能够处理复杂的业务流程,通过自定义工作流模型,可以实现审批、分发等业务逻辑。在Java源码中,我们可以看到如何使用Activiti的API来设计和执行工作流。 协作是Alfresco的重要特性,它支持版本控制...

Global site tag (gtag.js) - Google Analytics