Part 1 of MOB-378 Support for sub-types (and properties).

Supported for read cases. Property rendering driven from type model.

Fixed support for ID, XML, HTML and URI type properties.
Fixed ContentStreamUri property name.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13607 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-03-12 16:46:46 +00:00
parent e01d3dda4d
commit 894727b0cd
4 changed files with 91 additions and 35 deletions

View File

@@ -50,31 +50,13 @@
[#macro documentCMISProps node propfilter]
<cmis:properties>
[@filter propfilter "ObjectId"][@prop "ObjectId" node "ID"/][/@filter]
[#-- TODO: Spec issue - add root type id to meta-model --]
[#-- TODO: Spec issue: BaseType not a property --]
[@filter propfilter "BaseType"][@propvalue "BaseType" "document" "STRING"/][/@filter]
[@filter propfilter "ObjectTypeId"][@prop "ObjectTypeId" node "STRING"/][/@filter]
[@filter propfilter "CreatedBy"][@prop "CreatedBy" node "STRING"/][/@filter]
[@filter propfilter "CreationDate"][@prop "CreationDate" node "DATETIME"/][/@filter]
[@filter propfilter "LastModifiedBy"][@prop "LastModifiedBy" node "STRING"/][/@filter]
[@filter propfilter "LastModificationDate"][@prop "LastModificationDate" node "DATETIME"/][/@filter]
[#-- TODO: ChangeToken --]
[@filter propfilter "Name"][@prop "Name" node "STRING"/][/@filter]
[@filter propfilter "IsImmutable"][@prop "IsImmutable" node "BOOLEAN"/][/@filter]
[@filter propfilter "isLatestVersion"][@prop "IsLatestVersion" node "BOOLEAN"/][/@filter]
[@filter propfilter "IsMajorVersion"][@prop "IsMajorVersion" node "BOOLEAN"/][/@filter]
[@filter propfilter "isLatestMajorVersion"][@prop "IsLatestMajorVersion" node "BOOLEAN"/][/@filter]
[@filter propfilter "VersionLabel"][@prop "VersionLabel" node "STRING"/][/@filter]
[@filter propfilter "VersionSeriesId"][@prop "VersionSeriesId" node "ID"/][/@filter]
[@filter propfilter "IsVersionSeriesCheckedOut"][@prop "IsVersionSeriesCheckedOut" node "BOOLEAN"/][/@filter]
[@filter propfilter "VersionSeriesCheckedOutBy"][@prop "VersionSeriesCheckedOutBy" node "STRING"/][/@filter]
[@filter propfilter "VersionSeriesCheckedOutId"][@prop "VersionSeriesCheckedOutId" node "ID"/][/@filter]
[@filter propfilter "CheckinComment"][@prop "CheckinComment" node "STRING"/][/@filter]
[#-- TODO: ContentStreamAllowed --]
[@filter propfilter "ContentStreamLength"][@prop "ContentStreamLength" node "INTEGER"/][/@filter]
[@filter propfilter "ContentStreamMimeType"][@prop "ContentStreamMimeType" node "STRING"/][/@filter]
[@filter propfilter "ContentStreamFilename"][@prop "ContentStreamFilename" node "STRING"/][/@filter]
[@filter propfilter "ContentStreamURI"][@propvalue "ContentStreamURI" absurl(url.serviceContext) + "/api/node/" + node.nodeRef.storeRef.protocol + "/" + node.nodeRef.storeRef.identifier + "/" + node.nodeRef.id + "/content." + node.properties.name "STRING"/][/@filter]
[#assign typedef = cmistype(node)]
[#list typedef.propertyDefinitions?values as propdef]
[@filter propfilter propdef.propertyName][@prop propdef.propertyName node propdef.propertyType/][/@filter]
[/#list]
</cmis:properties>
[/#macro]
@@ -185,16 +167,13 @@
[#macro folderCMISProps node propfilter]
<cmis:properties>
[@filter propfilter "ObjectId"][@prop "ObjectId" node "ID"/][/@filter]
[#-- TODO: Spec issue - add root type id to meta-model --]
[#-- TODO: Spec issue: BaseType not a property --]
[@filter propfilter "BaseType"][@propvalue "BaseType" "folder" "STRING"/][/@filter]
[@filter propfilter "ObjectTypeId"][@prop "ObjectTypeId" node "STRING"/][/@filter]
[@filter propfilter "CreatedBy"][@prop "CreatedBy" node "STRING"/][/@filter]
[@filter propfilter "CreationDate"][@prop "CreationDate" node "DATETIME"/][/@filter]
[@filter propfilter "LastModifiedBy"][@prop "LastModifiedBy" node "STRING"/][/@filter]
[@filter propfilter "LastModificationDate"][@prop "LastModificationDate" node "DATETIME"/][/@filter]
[@filter propfilter "Name"][@prop "Name" node "STRING"/][/@filter]
[@filter propfilter "ParentId"][@prop "ParentId" node "ID"/][/@filter]
[#assign typedef = cmistype(node)]
[#list typedef.propertyDefinitions?values as propdef]
[@filter propfilter propdef.propertyName][@prop propdef.propertyName node propdef.propertyType/][/@filter]
[/#list]
</cmis:properties>
[/#macro]
@@ -279,7 +258,8 @@
[#elseif type == "DATETIME"]
<cmis:propertyDateTime cmis:name="${name}">[@datetimevalue value/]</cmis:propertyDateTime>
[#elseif type == "URI"]
<cmis:propertyUri cmis:name="${name}">[@urivalue value/]</cmis:propertyUri>
[#-- TODO: check validity of abs url prefix --]
<cmis:propertyUri cmis:name="${name}">[@urivalue absurl(url.serviceContext) + value/]</cmis:propertyUri>
[#elseif type == "ID"]
<cmis:propertyId cmis:name="${name}">[@idvalue value/]</cmis:propertyId>
[#-- TODO: remaining property types --]

View File

@@ -107,6 +107,11 @@
<constructor-arg><ref bean="CMISMapping"/></constructor-arg>
</bean>
</entry>
<entry key="cmistype">
<bean class="org.alfresco.repo.cmis.rest.CMISTypeMethod">
<constructor-arg><ref bean="CMISDictionaryService"/></constructor-arg>
</bean>
</entry>
<entry key="cmisproperty">
<bean class="org.alfresco.repo.cmis.rest.CMISPropertyValueMethod">
<constructor-arg><ref bean="CMISPropertyService"/></constructor-arg>

View File

@@ -45,7 +45,7 @@ import freemarker.template.TemplateModelException;
*
* @author davidc
*/
public final class CMISTypeIdMethod implements TemplateMethodModelEx
public class CMISTypeIdMethod implements TemplateMethodModelEx
{
private CMISMapping mappingService;

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.cmis.rest;
import java.util.List;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISTypeId;
import freemarker.template.TemplateModelException;
/**
* Custom FreeMarker Template language method.
* <p>
* Retrieve the CMIS Type for an Alfresco node
* <p>
* Usage: cmistype(TemplateNode node)
* cmistype(QName nodeType)
*
* @author davidc
*/
public class CMISTypeMethod extends CMISTypeIdMethod
{
private CMISDictionaryService dictionaryService;
/**
* Construct
*/
public CMISTypeMethod(CMISDictionaryService dictionaryService)
{
super(dictionaryService.getCMISMapping());
this.dictionaryService = dictionaryService;
}
/**
* @see freemarker.template.TemplateMethodModel#exec(java.util.List)
*/
@SuppressWarnings("unchecked")
public Object exec(List args) throws TemplateModelException
{
Object result = null;
Object typeId = super.exec(args);
if (typeId != null)
{
result = dictionaryService.getType((CMISTypeId)typeId);
}
return result;
}
}