Merge from SEAMIST3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10732 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2008-09-04 11:15:27 +00:00
parent fb231f88bc
commit 57c7de2df6
16 changed files with 627 additions and 29 deletions

View File

@@ -33,17 +33,27 @@
[#macro documentCMISProps node] [#macro documentCMISProps node]
<cmis:properties> <cmis:properties>
<cmis:propertyBoolean cmis:name="isImmutable">${cmisproperty(node, "IS_IMMUTABLE")?string}</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">${cmisproperty(node, "IS_LATEST_VERSION")?string}</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">${cmisproperty(node, "IS_MAJOR_VERSION")?string}</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">${cmisproperty(node, "IS_LATEST_MAJOR_VERSION")?string}</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isVersionSeriesCheckedOut">${cmisproperty(node, "VERSION_SERIES_IS_CHECKED_OUT")?string}</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="creationDate">${xmldate(node.properties.created)}</cmis:propertyDateTime> <cmis:propertyDateTime cmis:name="creationDate">${xmldate(node.properties.created)}</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="lastModificationDate">${xmldate(node.properties.modified)}</cmis:propertyDateTime> <cmis:propertyDateTime cmis:name="lastModificationDate">${xmldate(node.properties.modified)}</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">${node.nodeRef}</cmis:propertyID> <cmis:propertyID cmis:name="objectId">${node.nodeRef}</cmis:propertyID>
<cmis:propertyID cmis:name="versionSeriesID">${cmisproperty(node, "VERSION_SERIES_ID")}</cmis:propertyID>
<cmis:propertyID cmis:name="versionSeriesCheckedOutID">${cmisproperty(node, "VERSION_SERIES_CHECKED_OUT_ID")!""}</cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">${node.properties.content.size}</cmis:propertyInteger> <cmis:propertyInteger cmis:name="contentStreamLength">${node.properties.content.size}</cmis:propertyInteger>
<cmis:propertyString cmis:name="name">${node.name}</cmis:propertyString> <cmis:propertyString cmis:name="name">${node.name}</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">document</cmis:propertyString> <cmis:propertyString cmis:name="baseType">document</cmis:propertyString>
<cmis:propertyString cmis:name="objectType">document</cmis:propertyString> [#-- TODO --] <cmis:propertyString cmis:name="objectType">${cmistypeid(node)}</cmis:propertyString>
<cmis:propertyString cmis:name="createdBy">${node.properties.creator}</cmis:propertyString> <cmis:propertyString cmis:name="createdBy">${node.properties.creator}</cmis:propertyString>
<cmis:propertyString cmis:name="lastModifiedBy">${node.properties.modifier}</cmis:propertyString> <cmis:propertyString cmis:name="lastModifiedBy">${node.properties.modifier}</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">${node.properties.content.mimetype}</cmis:propertyString> <cmis:propertyString cmis:name="contentStreamMimetype">${node.properties.content.mimetype}</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">${node.name}</cmis:propertyString> <cmis:propertyString cmis:name="contentStreamName">${node.name}</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">${cmisproperty(node, "VERSION_LABEL")!""}</cmis:propertyString>
<cmis:propertyString cmis:name="versionSeriesCheckedOutBy">${cmisproperty(node, "VERSION_SERIES_CHECKED_OUT_BY")!""}</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">${cmisproperty(node, "CHECKIN_COMMENT")!""}</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content</cmis:propertyURI> <cmis:propertyURI cmis:name="contentStreamURI">${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content</cmis:propertyURI>
</cmis:properties> </cmis:properties>
[/#macro] [/#macro]
@@ -117,7 +127,10 @@
[#macro folderCMISLinks node] [#macro folderCMISLinks node]
<link rel="cmis-allowableactions" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/permissions"/> <link rel="cmis-allowableactions" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/permissions"/>
<link rel="cmis-relationships" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/associations"/> <link rel="cmis-relationships" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/associations"/>
<link rel="cmis-parent" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/parent"/> [#if cmisproperty(node, "PARENT")??]
<link rel="cmis-parent" href="${absurl(url.serviceContext)}/api/node/${node.parent.nodeRef.storeRef.protocol}/${node.parent.nodeRef.storeRef.identifier}/${node.parent.nodeRef.id}"/>
<link rel="cmis-folderparent" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/parent"/>
[/#if]
<link rel="cmis-children" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/children"/> <link rel="cmis-children" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/children"/>
<link rel="cmis-descendants" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/descendants"/> <link rel="cmis-descendants" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/descendants"/>
<link rel="cmis-type" href="${absurl(url.serviceContext)}/api/type/${cmistypeid(node)}"/> <link rel="cmis-type" href="${absurl(url.serviceContext)}/api/type/${cmistypeid(node)}"/>
@@ -128,9 +141,9 @@
<cmis:propertyDateTime cmis:name="creationDate">${xmldate(node.properties.created)}</cmis:propertyDateTime> <cmis:propertyDateTime cmis:name="creationDate">${xmldate(node.properties.created)}</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="lastModificationDate">${xmldate(node.properties.modified)}</cmis:propertyDateTime> <cmis:propertyDateTime cmis:name="lastModificationDate">${xmldate(node.properties.modified)}</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">${node.nodeRef}</cmis:propertyID> <cmis:propertyID cmis:name="objectId">${node.nodeRef}</cmis:propertyID>
<cmis:propertyID cmis:name="parent">${node.parent.nodeRef}</cmis:propertyID> <cmis:propertyID cmis:name="parent">${cmisproperty(node, "PARENT")!""}</cmis:propertyID>
<cmis:propertyString cmis:name="name">${node.name}</cmis:propertyString> <cmis:propertyString cmis:name="name">${node.name}</cmis:propertyString>
<cmis:propertyString cmis:name="objectType">document</cmis:propertyString> [#-- TODO --] <cmis:propertyString cmis:name="objectType">${cmistypeid(node)}</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">folder</cmis:propertyString> <cmis:propertyString cmis:name="baseType">folder</cmis:propertyString>
<cmis:propertyString cmis:name="createdBy">${node.properties.creator}</cmis:propertyString> <cmis:propertyString cmis:name="createdBy">${node.properties.creator}</cmis:propertyString>
<cmis:propertyString cmis:name="lastModifiedBy">${node.properties.modifier}</cmis:propertyString> <cmis:propertyString cmis:name="lastModifiedBy">${node.properties.modifier}</cmis:propertyString>
@@ -166,7 +179,7 @@
[/#macro] [/#macro]
[#macro typedefCMISProps typedef includeProperties=true includeInheritedProperties=true] [#macro typedefCMISProps typedef includeProperties=true includeInheritedProperties=true]
<cmis:type> <cmis:type xmlns:cmis="http://www.cmis.org/2008/05"> [#-- TODO: spec issue 40, remove ns decl --]
<cmis:objectId>${typedef.objectTypeId}</cmis:objectId> <cmis:objectId>${typedef.objectTypeId}</cmis:objectId>
<cmis:baseType>[@cmisBaseType typedef.rootTypeQueryName/]</cmis:baseType> [#-- TODO: remove spec issue 36 --] <cmis:baseType>[@cmisBaseType typedef.rootTypeQueryName/]</cmis:baseType> [#-- TODO: remove spec issue 36 --]
<cmis:lastModifiedBy>${xmldate(date)}</cmis:lastModifiedBy> [#-- TODO: remove spec issue 36 --] <cmis:lastModifiedBy>${xmldate(date)}</cmis:lastModifiedBy> [#-- TODO: remove spec issue 36 --]

View File

@@ -1,13 +1,14 @@
<#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/> [#ftl]
[#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/]
<?xml version="1.0" encoding='utf-8'?> <?xml version="1.0" encoding='utf-8'?>
<service <@nsLib.serviceNS/>> <service [@nsLib.serviceNS/]>
<workspace cmis:id="${server.id}"> <workspace cmis:id="${server.id}">
<atom:title>${server.name}</atom:title> <atom:title>${server.name}</atom:title>
<cmis:repositoryInfo> <cmis:repositoryInfo>
<cmis:repositoryId>${server.id}</cmis:repositoryId> <cmis:repositoryId>${server.id}</cmis:repositoryId>
<cmis:repositoryName>${server.name}</cmis:repositoryName> <cmis:repositoryName>${server.name}</cmis:repositoryName>
<cmis:repositoryDescription></cmis:repositoryDescription> <#-- TODO --> <cmis:repositoryDescription></cmis:repositoryDescription> [#-- TODO --]
<cmis:vendorName>Alfresco</cmis:vendorName> <cmis:vendorName>Alfresco</cmis:vendorName>
<cmis:productName>Alfresco Repository (${server.edition})</cmis:productName> <cmis:productName>Alfresco Repository (${server.edition})</cmis:productName>
<cmis:productVersion>${server.version}</cmis:productVersion> <cmis:productVersion>${server.version}</cmis:productVersion>
@@ -16,9 +17,9 @@
<cmis:capabilityUnfiling>false</cmis:capabilityUnfiling> <cmis:capabilityUnfiling>false</cmis:capabilityUnfiling>
<cmis:capabilityVersionSpecificFiling>false</cmis:capabilityVersionSpecificFiling> <cmis:capabilityVersionSpecificFiling>false</cmis:capabilityVersionSpecificFiling>
<cmis:capabilityPWCUpdateable>true</cmis:capabilityPWCUpdateable> <cmis:capabilityPWCUpdateable>true</cmis:capabilityPWCUpdateable>
<cmis:capabilityAllVersionsSearchable>false</cmis:capabilityAllVersionsSearchable> <cmis:capabilityAllVersionsSearchable>${allVersionsSearchable?string}</cmis:capabilityAllVersionsSearchable>
<cmis:capabilityJoin>noJoin</cmis:capabilityJoin> <cmis:capabilityJoin>[@capabilityJoin joinSupport/]</cmis:capabilityJoin>
<cmis:capabilityFullText>fulltextandstructured</cmis:capabilityFullText> <cmis:capabilityFullText>[@capabilityFullText fullTextSupport/]</cmis:capabilityFullText>
</cmis:capabilities> </cmis:capabilities>
<cmis:cmisVersionsSupported>${cmisVersion}</cmis:cmisVersionsSupported> <cmis:cmisVersionsSupported>${cmisVersion}</cmis:cmisVersionsSupported>
<cmis:repositorySpecificInformation></cmis:repositorySpecificInformation> <cmis:repositorySpecificInformation></cmis:repositorySpecificInformation>
@@ -39,3 +40,10 @@
</workspace> </workspace>
</service> </service>
[#macro capabilityJoin join]
[#if join = "NO_JOIN_SUPPORT"]noJoin[#elseif join = "INNER_JOIN_SUPPORT"]innerOnly[#elseif join = "INNER_AND_OUTER_JOIN_SUPPORT"]innerAndOuter[/#if][/#macro]
[#macro capabilityFullText fulltext]
[#if fulltext = "NO_FULL_TEXT"]none[#elseif fulltext = "FULL_TEXT_ONLY"]fulltextonly[#elseif fulltext = "FULL_TEXT_AND_STRUCTURED"]fulltextandstructured[/#if][/#macro]

View File

@@ -1,2 +1,5 @@
model.cmisVersion = cmis.version; model.cmisVersion = cmis.version;
model.defaultRootFolderPath = cmis.defaultRootFolderPath; model.defaultRootFolderPath = cmis.defaultRootFolderPath;
model.allVersionsSearchable = cmis.allVersionsSearchable;
model.joinSupport = cmis.joinSupport;
model.fullTextSupport = cmis.fullTextSearchSupport;

View File

@@ -31,7 +31,6 @@ script:
var description = entry.summary; var description = entry.summary;
var updated = entry.updated; var updated = entry.updated;
var author = (entry.author !== null) ? entry.author.name : null; var author = (entry.author !== null) ? entry.author.name : null;
var content = entry.content;
var cmisProperties = entry.getExtension(atom.names.cmis_properties); var cmisProperties = entry.getExtension(atom.names.cmis_properties);
var baseType = (cmisProperties !== null) ? cmisProperties.baseType : null; var baseType = (cmisProperties !== null) ? cmisProperties.baseType : null;
@@ -40,20 +39,34 @@ script:
if (baseType === null || baseType == "document") if (baseType === null || baseType == "document")
{ {
// TODO: objectTypeId to Alfresco content type
var node = model.parent.createFile(name); var node = model.parent.createFile(name);
node.properties.title = title; node.properties.title = title;
node.properties.description = description; node.properties.description = description;
if (content !== null)
// write entry content
if (entry.content != null)
{ {
node.content = content; if (entry.contentType !== null && entry.contentType == "MEDIA")
{
node.properties.content.write(entry.contentStream);
}
else
{
node.content = entry.content;
}
node.properties.content.encoding = "UTF-8"; node.properties.content.encoding = "UTF-8";
node.properties.content.mimetype = atom.toMimeType(entry); node.properties.content.mimetype = atom.toMimeType(entry);
} }
node.save(); node.save();
model.node = node; model.node = node;
// TODO: versioningState argument (CheckedOut/CheckedInMinor/CheckedInMajor)
} }
else if (baseType == "folder") else if (baseType == "folder")
{ {
// TODO: objectTypeId to Alfresco content type
var node = model.parent.createFolder(name); var node = model.parent.createFolder(name);
node.properties.title = title; node.properties.title = title;
node.properties.description = description; node.properties.description = description;

View File

@@ -4,8 +4,8 @@
[#compress] [#compress]
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<entry [@nsLib.entryNS/]> [#-- <entry> TODO: spec issue 40 --]
[@entryLib.typedef typedef true includeInheritedProperties/] [@entryLib.typedef typedef true includeInheritedProperties/]
</entry> [#-- </entry> TODO: spec issue 40 --]
[/#compress] [/#compress]

View File

@@ -107,6 +107,11 @@
<constructor-arg><ref bean="CMISMapping"/></constructor-arg> <constructor-arg><ref bean="CMISMapping"/></constructor-arg>
</bean> </bean>
</entry> </entry>
<entry key="cmisproperty">
<bean class="org.alfresco.repo.cmis.rest.CMISPropertyValueMethod">
<constructor-arg><ref bean="CMISPropertyService"/></constructor-arg>
</bean>
</entry>
</map> </map>
</property> </property>
<property name="registryFactory"> <property name="registryFactory">
@@ -398,6 +403,30 @@
<!-- CMIS API --> <!-- CMIS API -->
<!-- --> <!-- -->
<!-- CMIS custom mimetypes -->
<bean id="webscripts.cmis.adaptors" parent="webscripts.adaptorset">
<property name="readers">
<list>
<bean class="org.alfresco.repo.cmis.rest.CMISQueryReader" />
</list>
</property>
</bean>
<!-- Default Formats -->
<bean id="webscripts.cmis.formats" parent="webscripts.formatmap">
<property name="formats">
<props>
<prop key="cmissqlquery">application/cmisrequest+xml;type=query</prop>
</props>
</property>
<property name="mimetypes">
<props>
<prop key="application/cmisrequest+xml;type=query">cmissqlquery</prop>
</props>
</property>
</bean>
<!-- CMIS Javsascript API --> <!-- CMIS Javsascript API -->
<bean id="webscripts.js.cmis" parent="baseJavaScriptExtension" class="org.alfresco.repo.cmis.rest.CMISScript"> <bean id="webscripts.js.cmis" parent="baseJavaScriptExtension" class="org.alfresco.repo.cmis.rest.CMISScript">
<property name="extensionName"><value>cmis</value></property> <property name="extensionName"><value>cmis</value></property>
@@ -405,6 +434,7 @@
<property name="repository" ref="repositoryHelper" /> <property name="repository" ref="repositoryHelper" />
<property name="CMISService" ref="CMISService" /> <property name="CMISService" ref="CMISService" />
<property name="CMISDictionaryService" ref="CMISDictionaryService" /> <property name="CMISDictionaryService" ref="CMISDictionaryService" />
<property name="CMISQueryService" ref="CMISQueryService" />
<property name="paging" ref="webscripts.js.paging" /> <property name="paging" ref="webscripts.js.paging" />
</bean> </bean>

View File

@@ -0,0 +1,94 @@
/*
* 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.property.CMISPropertyService;
import org.alfresco.repo.template.TemplateNode;
import freemarker.ext.beans.BeanModel;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateScalarModel;
/**
* Custom FreeMarker Template language method.
* <p>
* Retrieve the CMIS property value for an Alfresco node
* <p>
* Usage: cmisproperty(TemplateNode node, String propertyName)
*
* @author davidc
*/
public final class CMISPropertyValueMethod implements TemplateMethodModelEx
{
private CMISPropertyService propertyService;
/**
* Construct
*/
public CMISPropertyValueMethod(CMISPropertyService propertyService)
{
this.propertyService = propertyService;
}
/**
* @see freemarker.template.TemplateMethodModel#exec(java.util.List)
*/
@SuppressWarnings("unchecked")
public Object exec(List args) throws TemplateModelException
{
Object result = null;
if (args.size() == 2)
{
Object arg0 = args.get(0);
if (arg0 instanceof BeanModel)
{
// extract node
TemplateNode node = null;
Object wrapped = ((BeanModel)arg0).getWrappedObject();
if (wrapped != null && wrapped instanceof TemplateNode)
{
node = (TemplateNode)wrapped;
}
// extract property name
String propertyName = null;
Object arg1 = args.get(1);
if (arg1 instanceof TemplateScalarModel)
{
propertyName = ((TemplateScalarModel)arg1).getAsString();
}
// retrieve property value
result = propertyService.getProperty(node.getNodeRef(), propertyName);
}
}
return result;
}
}

View File

@@ -0,0 +1,137 @@
/*
* 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.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.util.Content;
import org.alfresco.web.scripts.FormatReader;
import org.alfresco.web.scripts.WebScriptException;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptResponse;
/**
* Convert application/cmisrequest+xml;type=query to class String.
*
* @author davidc
*/
public class CMISQueryReader implements FormatReader<String>
{
/* (non-Javadoc)
* @see org.alfresco.web.scripts.FormatReader#getDestinationClass()
*/
public Class<String> getDestinationClass()
{
return String.class;
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.FormatReader#getSourceMimetype()
*/
public String getSourceMimetype()
{
return "application/cmisrequest+xml;type=query";
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.FormatReader#read(org.alfresco.web.scripts.WebScriptRequest)
*/
public String read(WebScriptRequest req)
{
Content content = req.getContent();
if (content == null)
{
throw new WebScriptException("Failed to convert request to String");
}
try
{
InputStreamReader reader;
if (content.getEncoding() != null)
{
reader = new InputStreamReader(content.getInputStream(), content.getEncoding());
}
else
{
reader = new InputStreamReader(content.getInputStream());
}
StringWriter writer = new StringWriter();
try
{
char[] buffer = new char[4096];
int bytesRead = -1;
while ((bytesRead = reader.read(buffer)) != -1)
{
writer.write(buffer, 0, bytesRead);
}
writer.flush();
return writer.toString();
}
finally
{
reader.close();
writer.close();
}
}
catch(UnsupportedEncodingException e)
{
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Failed to convert Query statement", e);
}
catch(IOException e)
{
throw new WebScriptException("Failed to convert Query statement", e);
}
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.FormatReader#createScriptParameters(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
*/
public Map<String, Object> createScriptParameters(WebScriptRequest req, WebScriptResponse res)
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("query", req.parseContent());
return params;
}
/* (non-Javadoc)
* @see org.alfresco.web.scripts.FormatReader#createTemplateParameters(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
*/
public Map<String, Object> createTemplateParameters(WebScriptRequest req, WebScriptResponse res)
{
Map<String, Object> params = new HashMap<String, Object>();
params.put("query", req.parseContent());
return params;
}
}

View File

@@ -32,6 +32,9 @@ import org.alfresco.cmis.CMISService.TypesFilter;
import org.alfresco.cmis.dictionary.CMISDictionaryService; import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISTypeDefinition; import org.alfresco.cmis.dictionary.CMISTypeDefinition;
import org.alfresco.cmis.dictionary.CMISTypeId; import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.cmis.search.CMISQueryService;
import org.alfresco.cmis.search.FullTextSearchSupport;
import org.alfresco.cmis.search.JoinSupport;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.jscript.BaseScopableProcessorExtension; import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
import org.alfresco.repo.jscript.ScriptNode; import org.alfresco.repo.jscript.ScriptNode;
@@ -51,12 +54,13 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/ */
public class CMISScript extends BaseScopableProcessorExtension public class CMISScript extends BaseScopableProcessorExtension
{ {
private static final TypesFilter defaultTypesFilter = TypesFilter.FoldersAndDocuments; private static final TypesFilter defaultTypesFilter = TypesFilter.Any;
private ServiceRegistry services; private ServiceRegistry services;
private Repository repository; private Repository repository;
private CMISService cmisService; private CMISService cmisService;
private CMISDictionaryService cmisDictionaryService; private CMISDictionaryService cmisDictionaryService;
private CMISQueryService cmisQueryService;
private Paging paging; private Paging paging;
@@ -110,6 +114,16 @@ public class CMISScript extends BaseScopableProcessorExtension
this.cmisDictionaryService = cmisDictionaryService; this.cmisDictionaryService = cmisDictionaryService;
} }
/**
* Set the CMIS Query Service
*
* @param cmisQueryService
*/
public void setCMISQueryService(CMISQueryService cmisQueryService)
{
this.cmisQueryService = cmisQueryService;
}
/** /**
* Gets the supported CMIS Version * Gets the supported CMIS Version
* *
@@ -367,7 +381,43 @@ public class CMISScript extends BaseScopableProcessorExtension
return null; return null;
} }
} }
//
// SQL Query
//
/**
* Can you query non-latest versions of a document.
*
* The current latest version is always searchable according to the type definition.
*
* @return
*/
public boolean getAllVersionsSearchable()
{
return cmisQueryService.getAllVersionsSearchable();
}
/**
* Get the join support level in queries.
*
* @return
*/
public JoinSupport getJoinSupport()
{
return cmisQueryService.getJoinSupport();
}
/**
* Get the full text search support level in queries.
*
* @return
*/
public FullTextSearchSupport getFullTextSearchSupport()
{
return cmisQueryService.getFullTextSearchSupport();
}
/** /**
* Resolve to a Types Filter * Resolve to a Types Filter
* *

View File

@@ -146,7 +146,13 @@ public class CMISTest extends BaseCMISWebScriptTest
private Entry createFolder(IRI parent, String name) private Entry createFolder(IRI parent, String name)
throws Exception throws Exception
{ {
String createFolder = loadString("/cmis/rest/createfolder.atomentry.xml"); return createFolder(parent, name, "/cmis/rest/createfolder.atomentry.xml");
}
private Entry createFolder(IRI parent, String name, String atomEntryFile)
throws Exception
{
String createFolder = loadString(atomEntryFile);
createFolder = createFolder.replace("${NAME}", name); createFolder = createFolder.replace("${NAME}", name);
Response res = sendRequest(new PostRequest(parent.toString(), createFolder, Format.ATOMENTRY.mimetype()), 201, getAtomValidator()); Response res = sendRequest(new PostRequest(parent.toString(), createFolder, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(res); assertNotNull(res);
@@ -165,7 +171,13 @@ public class CMISTest extends BaseCMISWebScriptTest
private Entry createDocument(IRI parent, String name) private Entry createDocument(IRI parent, String name)
throws Exception throws Exception
{ {
String createFile = loadString("/cmis/rest/createdocument.atomentry.xml"); return createDocument(parent, name, "/cmis/rest/createdocument.atomentry.xml");
}
private Entry createDocument(IRI parent, String name, String atomEntryFile)
throws Exception
{
String createFile = loadString(atomEntryFile);
name = name + " " + System.currentTimeMillis(); name = name + " " + System.currentTimeMillis();
createFile = createFile.replace("${NAME}", name); createFile = createFile.replace("${NAME}", name);
Response res = sendRequest(new PostRequest(parent.toString(), createFile, Format.ATOMENTRY.mimetype()), 201, getAtomValidator()); Response res = sendRequest(new PostRequest(parent.toString(), createFile, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
@@ -272,6 +284,30 @@ public class CMISTest extends BaseCMISWebScriptTest
assertNotNull(children); assertNotNull(children);
int entriesBefore = children.getEntries().size(); int entriesBefore = children.getEntries().size();
Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument"); Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument");
Response documentContentRes = sendRequest(new GetRequest(document.getContentSrc().toString()), 200);
String resContent = documentContentRes.getContentAsString();
assertEquals("test content " + document.getTitle(), resContent);
Feed feedFolderAfter = getFeed(childrenLink.getHref());
int entriesAfter = feedFolderAfter.getEntries().size();
assertEquals(entriesBefore +1, entriesAfter);
Entry entry = feedFolderAfter.getEntry(document.getId().toString());
assertNotNull(entry);
}
public void testCreateDocumentBase64()
throws Exception
{
Entry testFolder = createTestFolder("testCreateDocumentBase64");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Feed children = getFeed(childrenLink.getHref());
assertNotNull(children);
int entriesBefore = children.getEntries().size();
Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument", "/cmis/rest/createdocumentBase64.atomentry.xml");
Response documentContentRes = sendRequest(new GetRequest(document.getContentSrc().toString()), 200);
String testContent = loadString("/cmis/rest/createdocumentBase64.txt");
String resContent = documentContentRes.getContentAsString();
assertEquals(testContent, resContent);
Feed feedFolderAfter = getFeed(childrenLink.getHref()); Feed feedFolderAfter = getFeed(childrenLink.getHref());
int entriesAfter = feedFolderAfter.getEntries().size(); int entriesAfter = feedFolderAfter.getEntries().size();
assertEquals(entriesBefore +1, entriesAfter); assertEquals(entriesBefore +1, entriesAfter);
@@ -396,6 +432,50 @@ public class CMISTest extends BaseCMISWebScriptTest
assertEquals(4, nextCount); assertEquals(4, nextCount);
assertEquals(0, docIds.size()); assertEquals(0, docIds.size());
} }
public void testGetChildrenTypeFilter()
throws Exception
{
// create multiple children
Entry testFolder = createTestFolder("testChildrenTypeFilter");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry document = createDocument(childrenLink.getHref(), "testChildren1");
assertNotNull(document);
Entry folder = createFolder(childrenLink.getHref(), "testChildren2");
assertNotNull(folder);
// invalid type filter
Map<String, String> args = new HashMap<String, String>();
args.put("types", "Invalid");
Response invalidRes = sendRequest(new GetRequest(childrenLink.getHref().toString()).setArgs(args), 400);
assertNotNull(invalidRes);
// no filter
Feed noFilters = getFeed(childrenLink.getHref());
assertNotNull(noFilters);
assertEquals(2, noFilters.getEntries().size());
// any filter
args.put("types", "Any");
Feed any = getFeed(childrenLink.getHref(), args);
assertNotNull(any);
assertEquals(2, any.getEntries().size());
// folders filter
args.put("types", "Folders");
Feed folders = getFeed(childrenLink.getHref(), args);
assertNotNull(folders);
assertEquals(1, folders.getEntries().size());
assertNotNull(folders.getEntry(folder.getId().toString()));
// documents filter
args.put("types", "Documents");
Feed documents = getFeed(childrenLink.getHref(), args);
assertNotNull(documents);
assertEquals(1, documents.getEntries().size());
assertNotNull(documents.getEntry(document.getId().toString()));
}
public void testGetParent() public void testGetParent()
throws Exception throws Exception
@@ -405,7 +485,7 @@ public class CMISTest extends BaseCMISWebScriptTest
assertNotNull(childrenLink); assertNotNull(childrenLink);
Entry childFolder = createFolder(childrenLink.getHref(), "testParentChild"); Entry childFolder = createFolder(childrenLink.getHref(), "testParentChild");
assertNotNull(childFolder); assertNotNull(childFolder);
Link parentLink = childFolder.getLink(CMISConstants.REL_PARENT); Link parentLink = childFolder.getLink(CMISConstants.REL_FOLDERPARENT);
assertNotNull(parentLink); assertNotNull(parentLink);
// ensure there is parent 'testParent' // ensure there is parent 'testParent'
@@ -421,10 +501,14 @@ public class CMISTest extends BaseCMISWebScriptTest
assertNotNull(parentsToRoot); assertNotNull(parentsToRoot);
assertEquals(4, parentsToRoot.getEntries().size()); assertEquals(4, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId()); assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
assertNotNull(parentsToRoot.getEntries().get(0).getLink(CMISConstants.REL_PARENT));
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId()); assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
assertNotNull(parentsToRoot.getEntries().get(1).getLink(CMISConstants.REL_PARENT));
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId()); assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
assertNotNull(parentsToRoot.getEntries().get(2).getLink(CMISConstants.REL_PARENT));
Feed root = getFeed(getRootCollection(getRepository())); Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId()); assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT));
} }
public void testGetParents() public void testGetParents()
@@ -451,10 +535,14 @@ public class CMISTest extends BaseCMISWebScriptTest
assertNotNull(parentsToRoot); assertNotNull(parentsToRoot);
assertEquals(4, parentsToRoot.getEntries().size()); assertEquals(4, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId()); assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
assertNotNull(parentsToRoot.getEntries().get(0).getLink(CMISConstants.REL_PARENT));
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId()); assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
assertNotNull(parentsToRoot.getEntries().get(1).getLink(CMISConstants.REL_PARENT));
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId()); assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
assertNotNull(parentsToRoot.getEntries().get(2).getLink(CMISConstants.REL_PARENT));
Feed root = getFeed(getRootCollection(getRepository())); Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId()); assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
assertNull(parentsToRoot.getEntries().get(3).getLink(CMISConstants.REL_PARENT));
} }
public void testDelete() public void testDelete()
@@ -546,6 +634,7 @@ public class CMISTest extends BaseCMISWebScriptTest
// create document for checkout // create document for checkout
Entry document = createDocument(childrenLink.getHref(), "testCheckout"); Entry document = createDocument(childrenLink.getHref(), "testCheckout");
CMISProperties docProps = document.getExtension(CMISConstants.PROPERTIES);
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator()); Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes); assertNotNull(documentRes);
String documentXML = documentRes.getContentAsString(); String documentXML = documentRes.getContentAsString();
@@ -555,7 +644,16 @@ public class CMISTest extends BaseCMISWebScriptTest
IRI checkedoutHREF = getCheckedOutCollection(getRepository()); IRI checkedoutHREF = getCheckedOutCollection(getRepository());
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator()); Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes); assertNotNull(pwcRes);
// TODO: test private working copy properties String pwcXml = pwcRes.getContentAsString();
assertNotNull(pwcXml);
Entry pwc = abdera.parseEntry(new StringReader(pwcXml), null);
assertNotNull(pwc);
CMISProperties pwcProps = pwc.getExtension(CMISConstants.PROPERTIES);
assertNotNull(pwcProps);
assertTrue(pwcProps.isVersionSeriesCheckedOut());
assertEquals(docProps.getObjectId(), pwcProps.getVersionSeriesId());
assertEquals(pwcProps.getObjectId(), pwcProps.getVersionSeriesCheckedOutId());
assertNotNull(pwcProps.getVersionSeriesCheckedOutBy());
// test getCheckedOut is updated // test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES); CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
@@ -642,6 +740,16 @@ public class CMISTest extends BaseCMISWebScriptTest
assertNotNull(checkedout); assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size()); assertEquals(1, checkedout.getEntries().size());
// test version properties of checked-out item
// test checked-in version properties
Entry checkedoutdoc = getEntry(document.getSelfLink().getHref());
CMISProperties checkedoutdocProps = checkedoutdoc.getExtension(CMISConstants.PROPERTIES);
assertNotNull(checkedoutdocProps);
assertTrue(checkedoutdocProps.isVersionSeriesCheckedOut());
assertEquals(checkedoutdocProps.getObjectId(), checkedoutdocProps.getVersionSeriesId());
assertNotNull(checkedoutdocProps.getVersionSeriesCheckedOutId());
assertNotNull(checkedoutdocProps.getVersionSeriesCheckedOutBy());
// test update of private working copy // test update of private working copy
String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml"); String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml");
String guid = GUID.generate(); String guid = GUID.generate();
@@ -683,6 +791,15 @@ public class CMISTest extends BaseCMISWebScriptTest
assertEquals("text/plain", updatedDoc.getContentMimeType().toString()); assertEquals("text/plain", updatedDoc.getContentMimeType().toString());
Response updatedContentRes = sendRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200); Response updatedContentRes = sendRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, updatedContentRes.getContentAsString()); assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
// test checked-in version properties
CMISProperties updatedProps = updatedDoc.getExtension(CMISConstants.PROPERTIES);
assertNotNull(updatedProps);
assertFalse(updatedProps.isVersionSeriesCheckedOut());
assertEquals(updatedProps.getObjectId(), updatedProps.getVersionSeriesId());
assertEquals("", updatedProps.getVersionSeriesCheckedOutId());
assertEquals("", updatedProps.getVersionSeriesCheckedOutBy());
assertEquals(guid, updatedProps.getCheckinComment());
} }
public void testUpdateOnCheckIn() public void testUpdateOnCheckIn()
@@ -846,6 +963,38 @@ public class CMISTest extends BaseCMISWebScriptTest
}; };
} }
public void testGetTypeDefinition()
throws Exception
{
// retrieve test folder for checkins
Entry testFolder = createTestFolder("testGetEntryTypeDefinition");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
// create document
Entry document = createDocument(childrenLink.getHref(), "testGetEntryTypeDefinitionDoc");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
// create folder
Entry folder = createFolder(childrenLink.getHref(), "testGetEntryTypeDefinitionFolder");
Response folderRes = sendRequest(new GetRequest(folder.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(folderRes);
// retrieve children
Feed children = getFeed(childrenLink.getHref());
for (Entry entry : children.getEntries())
{
// get type definition
Link typeLink = entry.getLink(CMISConstants.REL_TYPE);
assertNotNull(typeLink);
// TODO: spec issue 40 - use getEntry when wrapped as entry
Response type = sendRequest(new GetRequest(typeLink.getHref().toString()), 200, getAtomValidator());
//Entry type = getEntry(typeLink.getHref());
assertNotNull(type);
// TODO: test correct type for entry & properties of type
}
}
// public void testUnfiled() // public void testUnfiled()
// { // {
// } // }

View File

@@ -28,7 +28,6 @@ import java.util.List;
import org.alfresco.cmis.dictionary.CMISMapping; import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.dictionary.CMISTypeId; import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.repo.template.TemplateNode; import org.alfresco.repo.template.TemplateNode;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
@@ -41,8 +40,8 @@ import freemarker.template.TemplateModelException;
* <p> * <p>
* Retrieve the CMIS Type Id for an Alfresco node * Retrieve the CMIS Type Id for an Alfresco node
* <p> * <p>
* Usage: cmisTypeId(ScriptNode node) * Usage: cmistypeid(TemplaateNode node)
* cmisTypeId(QName nodeType) * cmistypeid(QName nodeType)
* *
* @author davidc * @author davidc
*/ */
@@ -61,6 +60,7 @@ public final class CMISTypeIdMethod implements TemplateMethodModelEx
/** /**
* @see freemarker.template.TemplateMethodModel#exec(java.util.List) * @see freemarker.template.TemplateMethodModel#exec(java.util.List)
*/ */
@SuppressWarnings("unchecked")
public Object exec(List args) throws TemplateModelException public Object exec(List args) throws TemplateModelException
{ {
CMISTypeId result = null; CMISTypeId result = null;

View File

@@ -141,6 +141,7 @@ public abstract class BaseWebScriptTest extends TestCase
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("Request"); logger.debug("Request");
logger.debug(req.getMethod() + " " + req.getFullUri());
logger.debug(req.getBody() == null ? null : new String(req.getBody())); logger.debug(req.getBody() == null ? null : new String(req.getBody()));
} }

View File

@@ -47,15 +47,29 @@ public interface CMISConstants
public static final QName PROPERTIES = new QName(CMIS_200805_NS, "properties"); public static final QName PROPERTIES = new QName(CMIS_200805_NS, "properties");
public static final QName PROPERTY_STRING = new QName(CMIS_200805_NS, "propertyString"); public static final QName PROPERTY_STRING = new QName(CMIS_200805_NS, "propertyString");
public static final QName PROPERTY_ID = new QName(CMIS_200805_NS, "propertyID"); public static final QName PROPERTY_ID = new QName(CMIS_200805_NS, "propertyID");
public static final QName PROPERTY_BOOLEAN = new QName(CMIS_200805_NS, "propertyBoolean");
public static final QName PROPERTY_NAME = new QName(CMIS_200805_NS, "name"); public static final QName PROPERTY_NAME = new QName(CMIS_200805_NS, "name");
// CMIS Properties // CMIS Properties
public static final String PROP_OBJECTID = "objectId"; public static final String PROP_OBJECT_ID = "objectId";
public static final String PROP_BASETYPE = "baseType"; public static final String PROP_BASETYPE = "baseType";
public static final String PROP_IS_IMMUTABLE = "isImmutable";
public static final String PROP_IS_LATEST_VERSION = "isLatestVersion";
public static final String PROP_IS_MAJOR_VERSION = "isMajorVersion";
public static final String PROP_IS_LATEST_MAJOR_VERSION = "isLatestMajorVersion";
public static final String PROP_VERSION_LABEL = "versionLabel";
public static final String PROP_VERSION_SERIES_ID = "versionSeriesID";
public static final String PROP_VERSION_SERIES_IS_CHECKED_OUT = "isVersionSeriesCheckedOut";
public static final String PROP_VERSION_SERIES_CHECKED_OUT_BY = "versionSeriesCheckedOutBy";
public static final String PROP_VERSION_SERIES_CHECKED_OUT_ID = "versionSeriesCheckedOutID";
public static final String PROP_CHECKIN_COMMENT = "checkinComment";
// CMIS Relationships // CMIS Relationships
public static final String REL_CHILDREN = "cmis-children"; public static final String REL_CHILDREN = "cmis-children";
public static final String REL_PARENT = "cmis-parent"; public static final String REL_PARENT = "cmis-parent";
public static final String REL_FOLDERPARENT = "cmis-folderparent";
public static final String REL_PARENTS = "cmis-parents"; public static final String REL_PARENTS = "cmis-parents";
public static final String REL_ALLVERSIONS = "cmis-allversions"; public static final String REL_ALLVERSIONS = "cmis-allversions";
public static final String REL_TYPE = "cmis-type";
} }

View File

@@ -55,7 +55,7 @@ public class CMISProperties extends ElementWrapper
public String getObjectId() public String getObjectId()
{ {
return findPropertyID(CMISConstants.PROP_OBJECTID); return findPropertyID(CMISConstants.PROP_OBJECT_ID);
} }
public String getBaseType() public String getBaseType()
@@ -63,6 +63,57 @@ public class CMISProperties extends ElementWrapper
return findPropertyString(CMISConstants.PROP_BASETYPE); return findPropertyString(CMISConstants.PROP_BASETYPE);
} }
public boolean isImmutable()
{
return findPropertyBoolean(CMISConstants.PROP_IS_IMMUTABLE);
}
public boolean isLatestVersion()
{
return findPropertyBoolean(CMISConstants.PROP_IS_LATEST_VERSION);
}
public boolean isMajorVersion()
{
return findPropertyBoolean(CMISConstants.PROP_IS_MAJOR_VERSION);
}
public boolean isLatestMajorVersion()
{
return findPropertyBoolean(CMISConstants.PROP_IS_LATEST_MAJOR_VERSION);
}
public String getVersionLabel()
{
return findPropertyString(CMISConstants.PROP_VERSION_LABEL);
}
public String getVersionSeriesId()
{
return findPropertyID(CMISConstants.PROP_VERSION_SERIES_ID);
}
public boolean isVersionSeriesCheckedOut()
{
return findPropertyBoolean(CMISConstants.PROP_VERSION_SERIES_IS_CHECKED_OUT);
}
public String getVersionSeriesCheckedOutBy()
{
return findPropertyString(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_BY);
}
public String getVersionSeriesCheckedOutId()
{
return findPropertyID(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_ID);
}
public String getCheckinComment()
{
return findPropertyString(CMISConstants.PROP_CHECKIN_COMMENT);
}
private String findPropertyString(String name) private String findPropertyString(String name)
{ {
Element child = getFirstChild(CMISConstants.PROPERTY_STRING); Element child = getFirstChild(CMISConstants.PROPERTY_STRING);
@@ -91,4 +142,19 @@ public class CMISProperties extends ElementWrapper
return null; return null;
} }
private boolean findPropertyBoolean(String name)
{
Element child = getFirstChild(CMISConstants.PROPERTY_BOOLEAN);
while(child != null)
{
if (name.equals(child.getAttributeValue(CMISConstants.PROPERTY_NAME)))
{
return Boolean.valueOf(child.getText());
}
child = child.getNextSibling(CMISConstants.PROPERTY_BOOLEAN);
}
return false;
}
} }

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/2008/05">
<title>${NAME}</title>
<summary>${NAME} (summary)</summary>
<content type="text/plain">
VGhpcyBtZXRob2QgZm9sbG93cyB0aGUgQXRvbSBQdWJsaXNoaW5nIG1vZGVsIHdoZXJlIHRoZSBl
bnRyeSBkb2N1bWVudCwgYXRvbSBvciBjbWlzLCBpcyBwb3N0ZWQgdG8gdGhlIHJvb3Qgb3Igc3Bl
Y2lmaWMgZm9sZGVyIFVSSS4gIEZvciB1bmZpbGVkIGRvY3VtZW50cywgcG9zdCB0aGUgZG9jdW1l
bnQgdG8gdGhlIHVuZmlsZWQgY29sbGVjdGlvbi4gICBUaGUgZG9jdW1lbnQgd2lsbCBiZSBjcmVh
dGVkIGluIHRoZSBmb2xkZXIgcG9zdGVkLiBJZiB0aGUgZG9jdW1lbnQgaXMgcG9zdGVkIHRvIHRo
ZSByb290IGNvbGxlY3Rpb24gYW5kIGEgZm9sZGVyIHByb3BlcnR5IGlzIHNwZWNpZmllZCwgdGhl
biB0aGUgcmVwb3NpdG9yeSB3aWxsIGNyZWF0ZSB0aGUgZG9jdW1lbnQgaW4gdGhlIHNwZWNpZmll
ZCBmb2xkZXIuICBJZiB0aGUgY29udGVudCBzdHJlYW0gaXMgc3BlY2lmaWVkIG9uIGNyZWF0ZSwg
aXQgc2hvdWxkIGJlIGJhc2U2NCBlbmNvZGVkIGluIHRoZSBhdG9tIGVudHJ5Lg==
</content>
<cmis:properties>
<cmis:propertyString cmis:name="baseType">document</cmis:propertyString>
</cmis:properties>
</entry>

View File

@@ -0,0 +1 @@
This method follows the Atom Publishing model where the entry document, atom or cmis, is posted to the root or specific folder URI. For unfiled documents, post the document to the unfiled collection. The document will be created in the folder posted. If the document is posted to the root collection and a folder property is specified, then the repository will create the document in the specified folder. If the content stream is specified on create, it should be base64 encoded in the atom entry.