Merge from SEAMIST3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10726 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2008-09-04 10:56:47 +00:00
parent e22df58ebb
commit 86fa1c011f
80 changed files with 17833 additions and 2389 deletions

View File

@@ -0,0 +1,218 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint address="/RepositoryService" implementor="#dmRepositoryService" implementorClass="org.alfresco.repo.cmis.ws.DMRepositoryServicePort">
<jaxws:inInterceptors>
<ref local="saajInInterceptor" />
<ref local="wss4jInInterceptor" />
<ref local="authenticationInterceptor" />
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref local="saajOutInterceptor" />
<ref local="wss4jOutInterceptor" />
</jaxws:outInterceptors>
<jaxws:outFaultInterceptors>
<ref local="saajOutInterceptor" />
<ref local="wss4jOutInterceptor" />
</jaxws:outFaultInterceptors>
<jaxws:properties>
<entry key="mtom-enabled" value="false" />
</jaxws:properties>
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
</jaxws:endpoint>
<jaxws:endpoint address="/NavigationService" implementor="#dmNavigationService" implementorClass="org.alfresco.repo.cmis.ws.DMNavigationServicePort">
<jaxws:inInterceptors>
<ref local="saajInInterceptor" />
<ref local="wss4jInInterceptor" />
<ref local="authenticationInterceptor" />
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref local="saajOutInterceptor" />
<ref local="wss4jOutInterceptor" />
</jaxws:outInterceptors>
<jaxws:outFaultInterceptors>
<ref local="saajOutInterceptor" />
<ref local="wss4jOutInterceptor" />
</jaxws:outFaultInterceptors>
<jaxws:properties>
<entry key="mtom-enabled" value="false" />
</jaxws:properties>
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
</jaxws:endpoint>
<jaxws:endpoint address="/ObjectService" implementor="#dmObjectService" implementorClass="org.alfresco.repo.cmis.ws.DMObjectServicePort">
<jaxws:inInterceptors>
<ref local="saajInInterceptor" />
<ref local="wss4jInInterceptor" />
<ref local="authenticationInterceptor" />
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref local="saajOutInterceptor" />
<ref local="wss4jOutInterceptor" />
</jaxws:outInterceptors>
<jaxws:outFaultInterceptors>
<ref local="saajOutInterceptor" />
<ref local="wss4jOutInterceptor" />
</jaxws:outFaultInterceptors>
<jaxws:properties>
<entry key="mtom-enabled" value="true" />
</jaxws:properties>
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
</jaxws:endpoint>
<bean id="dmRepositoryService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<list>
<value>org.alfresco.repo.cmis.ws.RepositoryServicePort</value>
</list>
</property>
<property name="target">
<ref bean="dmRepositoryServiceTarget" />
</property>
<property name="interceptorNames">
<list>
<idref local="dmAbstractServiceTx" />
<idref local="exceptionPointcutAdvisor" />
</list>
</property>
</bean>
<bean id="dmNavigationService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<list>
<value>org.alfresco.repo.cmis.ws.NavigationServicePort</value>
</list>
</property>
<property name="target">
<ref bean="dmNavigationServiceTarget" />
</property>
<property name="interceptorNames">
<list>
<idref local="dmAbstractServiceTx" />
<idref local="exceptionPointcutAdvisor" />
</list>
</property>
</bean>
<bean id="dmObjectService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<list>
<value>org.alfresco.repo.cmis.ws.ObjectServicePort</value>
</list>
</property>
<property name="target">
<ref bean="dmObjectServiceTarget" />
</property>
<property name="interceptorNames">
<list>
<idref local="dmAbstractServiceTx" />
<idref local="exceptionPointcutAdvisor" />
</list>
</property>
</bean>
<bean id="dmAbstractServiceTx" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">${server.transaction.mode.readOnly}</prop>
<prop key="*">${server.transaction.mode.default}</prop>
</props>
</property>
</bean>
<bean id="dmRepositoryServiceTarget" parent="dmAbstractService" class="org.alfresco.repo.cmis.ws.DMRepositoryServicePort">
<property name="rootPath">
<value>workspace://SpacesStore/app:company_home</value>
</property>
</bean>
<bean id="dmNavigationServiceTarget" parent="dmAbstractService" class="org.alfresco.repo.cmis.ws.DMNavigationServicePort" />
<bean id="dmObjectServiceTarget" parent="dmAbstractService" class="org.alfresco.repo.cmis.ws.DMObjectServicePort" />
<bean id="dmAbstractService" abstract="true" class="org.alfresco.repo.cmis.ws.DMAbstractServicePort">
<property name="authenticationService" ref="authenticationService" />
<property name="personService" ref="personService" />
<property name="nodeService" ref="nodeService" />
<property name="dictionaryService" ref="dictionaryService" />
<property name="searchService" ref="searchService" />
<property name="namespaceService" ref="namespaceService" />
<property name="versionService" ref="versionService" />
<property name="checkOutCheckInService" ref="checkOutCheckInService" />
<property name="fileFolderService" ref="fileFolderService" />
</bean>
<bean id="exceptionPointcutAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
<property name="advice">
<bean class="org.alfresco.repo.cmis.ws.DMServicePortThrowsAdvice" />
</property>
</bean>
<!-- ========================================================================================================= -->
<bean id="saajInInterceptor" class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor" />
<bean id="saajOutInterceptor" class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
<bean id="wss4jInInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken Timestamp" />
<entry key="passwordType" value="PasswordText" />
<entry>
<key>
<value>passwordCallbackRef</value>
</key>
<ref local="authenticationTokenCallback" />
</entry>
</map>
</constructor-arg>
</bean>
<bean id="wss4jOutInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Timestamp" />
</map>
</constructor-arg>
</bean>
<bean id="authenticationTokenCallback" class="org.alfresco.repo.cmis.ws.AuthenticationTokenCallbackHandler">
<property name="authenticationService" ref="AuthenticationService" />
</bean>
<bean id="authenticationInterceptor" class="org.alfresco.repo.cmis.ws.AuthenticationInterceptor" />
</beans>

View File

@@ -23,6 +23,52 @@
<alf:icon>${absurl(url.context)}${node.icon16}</alf:icon>
</#macro>
<#-- -->
<#-- ATOM Entry for Version -->
<#-- -->
<#macro version node version>
<#-- ATOM syndication -->
${version.label} ${cropContent(node.properties.content, 50)}
<author><name>${node.properties.creator}</name></author>
<content type="${node.mimetype}" src="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content"/>
<id>urn:uuid:${node.id}</id>
<published>${xmldate(node.properties.created)}</published>
<summary>${node.properties.description!node.properties.title!cropContent(node.properties.content, 50)}</summary>
<title>${node.name}</title>
<updated>${xmldate(node.properties.modified)}</updated>
<link rel="self" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}"/>
<link rel="enclosure" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content" type="${node.mimetype}"/>
<#-- ATOM Publishing Protocol -->
<app:edited>${xmldate(node.properties.modified)}</app:edited>
<#-- Alfresco props -->
<alf:icon>${absurl(url.context)}${node.icon16}</alf:icon>
</#macro>
<#-- -->
<#-- ATOM Entry for Private Working Copy -->
<#-- -->
<#macro pwc node>
<#-- ATOM syndication -->
<author><name>${node.properties.creator}</name></author>
<content type="${node.mimetype}" src="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content"/>
<id>urn:uuid:${node.id}</id>
<published>${xmldate(node.properties.created)}</published>
<summary>${node.properties.description!node.properties.title!cropContent(node.properties.content, 50)}</summary>
<title>${node.name}</title>
<updated>${xmldate(node.properties.modified)}</updated>
<link rel="self" href="${absurl(url.serviceContext)}/api/pwc/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}"/>
<link rel="enclosure" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content" type="${node.mimetype}"/>
<#-- ATOM Publishing Protocol -->
<app:edited>${xmldate(node.properties.modified)}</app:edited>
<#-- TODO: the edit link refers to the updatable node resource, allowing updates on PWCs without checkin -->
<link rel="edit" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}"/>
<link rel="edit-media" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content" type="${node.mimetype}"/>
<#-- Alfresco props -->
<alf:icon>${absurl(url.context)}${node.icon16}</alf:icon>
</#macro>
<#-- -->
<#-- ATOM Entry for Folder -->
<#-- -->

View File

@@ -22,6 +22,30 @@
</cmis:properties>
</#macro>
<#-- -->
<#-- CMIS Extensions for Version -->
<#-- -->
<#macro version node version>
<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-parents" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/parents"/>
<link rel="cmis-allversions" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/versions"/>
<link rel="cmis-stream" href="${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content" type="${node.mimetype}"/>
<cmis:properties>
<cmis:objectId>${node.nodeRef}</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:createdBy>${node.properties.creator}</cmis:createdBy>
<cmis:creationDate>${xmldate(node.properties.created)}</cmis:creationDate>
<cmis:lastModifiedBy>${node.properties.modifier}</cmis:lastModifiedBy>
<cmis:lastModificationDate>${xmldate(node.properties.modified)}</cmis:lastModificationDate>
<cmis:contentStreamLength>${node.properties.content.size}</cmis:contentStreamLength>
<cmis:contentStreamMimetype>${node.properties.content.mimetype}</cmis:contentStreamMimetype>
<cmis:contentStreamName>${node.name}</cmis:contentStreamName>
<cmis:contentStreamUri>${absurl(url.serviceContext)}/api/node/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/content</cmis:contentStreamUri>
</cmis:properties>
</#macro>
<#-- -->
<#-- CMIS Extensions for Folder -->
<#-- -->

View File

@@ -19,9 +19,8 @@
<cmis:capabilityVersionSpecificFiling>false</cmis:capabilityVersionSpecificFiling>
<cmis:capabilityPWCUpdateable>true</cmis:capabilityPWCUpdateable>
<cmis:capabilityAllVersionsSearchable>false</cmis:capabilityAllVersionsSearchable>
<cmis:capabilityInnerJoin>true</cmis:capabilityInnerJoin>
<cmis:capabilityOuterJoin>true</cmis:capabilityOuterJoin>
<cmis:capabilityFullText>fulltextwithmetadata</cmis:capabilityFullText>
<cmis:capabilityJoin>innerAndOuter</cmis:capabilityJoin> <#-- TODO: check -->
<cmis:capabilityFullText>fulltextandstructured</cmis:capabilityFullText>
</cmis:capabilities>
<cmis:repositorySpecificInformation></cmis:repositorySpecificInformation>
</cmis:repositoryInfo>

View File

@@ -10,11 +10,8 @@
<#list results as child>
<entry>
<#if child.isDocument>
<@entryLib.document node=child/>
<@entryLib.pwc node=child/>
<@cmisLib.document node=child/>
<#else>
<@entryLib.folder node=child/>
<@cmisLib.folder node=child/>
</#if>
</entry>
</#list>

View File

@@ -3,6 +3,6 @@
<#import "/org/alfresco/cmis/cmis.lib.atom.ftl" as cmisLib/>
<?xml version="1.0" encoding="UTF-8"?>
<entry <@nsLib.entryNS/>>
<@entryLib.document node=pwc/>
<@entryLib.pwc node=pwc/>
<@cmisLib.document node=pwc/>
</entry>

View File

@@ -1,6 +1,6 @@
<webscript>
<shortname>Delete item</shortname>
<description>Delete item</description>
<description>Delete item (and cancel checkout for private working copies)</description>
<url>/api/node/{store_type}/{store_id}/{id}?includeChildren={includeChildren?}</url>
<url>/api/path/{store_type}/{store_id}/{id}?includeChildren={includeChildren?}</url>
<authentication>user</authentication>

View File

@@ -34,8 +34,7 @@ script:
}
}
// TODO: Checked-out documents - are they automatically cancelled?
// Note: checked-out documents are automatically unlocked if a private working copy is deleted
if (!node.remove())
{
status.code = 500;

View File

@@ -0,0 +1,13 @@
<#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/>
<#import "/org/alfresco/cmis/atomentry.lib.atom.ftl" as entryLib/>
<#import "/org/alfresco/cmis/cmis.lib.atom.ftl" as cmisLib/>
<?xml version="1.0" encoding="UTF-8"?>
<entry <@nsLib.entryNS/>>
<#if node.isDocument>
<@entryLib.document node=node/>
<@cmisLib.document node=node/>
<#else>
<@entryLib.folder node=node/>
<@cmisLib.folder node=node/>
</#if>
</entry>

View File

@@ -0,0 +1,61 @@
script:
{
// locate node
var pathSegments = url.match.split("/");
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/"));
model.node = cmis.findNode(pathSegments[2], reference);
if (model.node === null)
{
status.code = 404;
status.message = "Repository " + pathSegments[2] + " " + reference.join("/") + " not found";
status.redirect = true;
break script;
}
// TODO: check for appropriate permission
// ensure atom entry is posted
if (entry === null)
{
status.code = 400;
status.message = "Expected atom entry";
status.redirect = true;
break script;
}
// update properties
// NOTE: Only CMIS property name is updatable
// TODO: support for custom properties
var updated = false;
var name = entry.title;
if (name !== null)
{
model.node.name = name;
updated = true;
}
// update content, if provided in-line
var content = entry.content;
if (content !== null)
{
if (!model.node.isDocument)
{
status.code = 400;
status.message = "Cannot update content on folder " + pathSegments[2] + " " + reference.join("/");
status.redirect = true;
break script;
}
model.node.content = content;
model.node.properties.content.encoding = "UTF-8";
model.node.properties.content.mimetype = atom.toMimeType(entry);
updated = true;
}
// only save if an update actually occurred
if (updated)
{
model.node.save();
}
}

View File

@@ -0,0 +1,9 @@
<webscript>
<shortname>Update properties</shortname>
<description>Update the properties of the node</description>
<url>/api/node/{store_type}/{store_id}/{id}</url>
<url>/api/path/{store_type}/{store_id}/{id}</url>
<authentication>user</authentication>
<format default="atomentry">argument</format>
<cmis version="0.21"/>
</webscript>

View File

@@ -15,7 +15,7 @@
<@entryLib.folder node=node/>
<@cmisLib.folder node=node/>
</entry>
<#if recurse>
<#if recurse && node.id != rootNode.id>
<@parent node=node.parent recurse=true/>
</#if>
</#if>

View File

@@ -17,4 +17,5 @@ script:
// retrieve parent
var returnToRoot = cmis.findArg(args.returnToRoot, headers["CMIS-returnToRoot"]);
model.returnToRoot = returnToRoot == "true" ? true : false;
model.rootNode = cmis.defaultRootFolder;
}

View File

@@ -16,7 +16,7 @@
<@entryLib.folder node=node/>
<@cmisLib.folder node=node/>
</entry>
<#if recurse>
<#if recurse && node.id != rootNode.id>
<@parent node=node.parent recurse=true/>
</#if>
</#if>

View File

@@ -18,4 +18,5 @@ script:
// retrieve parent
var returnToRoot = cmis.findArg(args.returnToRoot, headers["CMIS-returnToRoot"]);
model.returnToRoot = returnToRoot == "true" ? true : false;
model.rootNode = cmis.defaultRootFolder;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Cancel Checkout</shortname>
<description>Cancel checkout of a private working copy</description>
<url>/api/pwc/{store_type}/{store_id}/{id}</url>
<authentication>user</authentication>
<format default="atomentry"/>
<cmis version="0.21"/>
</webscript>

View File

@@ -0,0 +1,27 @@
script:
{
// locate node
var pathSegments = url.match.split("/");
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/"));
var node = cmis.findNode("node", reference);
if (node === null || !node.hasAspect("cm:workingcopy"))
{
status.code = 404;
status.message = "Private working copy " + reference.join("/") + " not found";
status.redirect = true;
break script;
}
if (!node.hasPermission("CancelCheckOut"))
{
status.code = 403;
status.message = "Permission to cancel checkout is denied";
status.redirect = true;
break script;
}
node.cancelCheckout();
status.code = 204; // Success, but no response content
status.redirect = true;
}

View File

@@ -0,0 +1,8 @@
<#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/>
<#import "/org/alfresco/cmis/atomentry.lib.atom.ftl" as entryLib/>
<#import "/org/alfresco/cmis/cmis.lib.atom.ftl" as cmisLib/>
<?xml version="1.0" encoding="UTF-8"?>
<entry <@nsLib.entryNS/>>
<@entryLib.pwc node=node/>
<@cmisLib.document node=node/>
</entry>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Retrieve properties of PWC</shortname>
<description>Retrieves the properties of a private working copy</description>
<url>/api/pwc/{store_type}/{store_id}/{id}?filter={filter?}</url>
<authentication>user</authentication>
<format default="atomentry">argument</format>
<cmis version="0.21"/>
</webscript>

View File

@@ -0,0 +1,17 @@
script:
{
// locate node
var pathSegments = url.match.split("/");
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/"));
model.node = cmis.findNode("node", reference);
if (model.node === null || !model.node.hasAspect("cm:workingcopy"))
{
status.code = 404;
status.message = "Private working copy " + reference.join("/") + " not found";
status.redirect = true;
break script;
}
// TODO: property filters
}

View File

@@ -0,0 +1,8 @@
<#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/>
<#import "/org/alfresco/cmis/atomentry.lib.atom.ftl" as entryLib/>
<#import "/org/alfresco/cmis/cmis.lib.atom.ftl" as cmisLib/>
<?xml version="1.0" encoding="UTF-8"?>
<entry <@nsLib.entryNS/>>
<@entryLib.document node=node/>
<@cmisLib.document node=node/>
</entry>

View File

@@ -0,0 +1,67 @@
script:
{
// locate node
var pathSegments = url.match.split("/");
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/"));
var node = cmis.findNode("node", reference);
if (node === null || !node.hasAspect("cm:workingcopy"))
{
status.code = 404;
status.message = "Private working copy " + reference.join("/") + " not found";
status.redirect = true;
break script;
}
if (!node.hasPermission("CheckIn"))
{
status.code = 403;
status.message = "Permission to checkin is denied";
status.redirect = true;
break script;
}
if (entry !== null)
{
var updated = false;
// update properties
// NOTE: Only CMIS property name is updatable
// TODO: support for custom properties
var name = entry.title;
if (name !== null)
{
node.name = name;
updated = true;
}
// update content, if provided in-line
var content = entry.content;
if (content !== null)
{
if (!node.isDocument)
{
status.code = 400;
status.message = "Cannot update content on folder " + pathSegments[2] + " " + reference.join("/");
status.redirect = true;
break script;
}
node.content = content;
node.properties.content.encoding = "UTF-8";
node.properties.content.mimetype = atom.toMimeType(entry);
updated = true;
}
// only save if an update actually occurred
if (updated)
{
node.save();
}
}
// checkin
var comment = cmis.findArg(args.checkinComment, headers["CMIS-checkinComment"]);
var major = cmis.findArg(args.major, headers["CMIS-major"]);
major = (major === null || major == "true") ? true : false;
model.node = node.checkin(comment === null ? "" : comment, major);
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Checkin Private Working Copy</shortname>
<description>Checkin private working copy</description>
<url>/api/pwc/{store_type}/{store_id}/{id}?checkinComment={checkinComment?}&amp;major={major?}</url>
<authentication>user</authentication>
<format default="atomentry"/>
<cmis version="0.21"/>
</webscript>

View File

@@ -0,0 +1,14 @@
<#import "/org/alfresco/cmis/ns.lib.atom.ftl" as nsLib/>
<#import "/org/alfresco/cmis/atomfeed.lib.atom.ftl" as feedLib/>
<#import "/org/alfresco/cmis/atomentry.lib.atom.ftl" as entryLib/>
<#import "/org/alfresco/cmis/cmis.lib.atom.ftl" as cmisLib/>
<?xml version="1.0" encoding="UTF-8"?>
<feed <@nsLib.feedNS/>>
<@feedLib.generic id="urn:uuid:${node.id}-versions" title="Versions of ${node.displayPath}"/>
<#list nodes as version>
<entry>
<@entryLib.version node=version version=versions[version_index]/>
<@cmisLib.version node=version version=versions[version_index]/>
</entry>
</#list>
</feed>

View File

@@ -0,0 +1,9 @@
<webscript>
<shortname>Retrieve all versions</shortname>
<description>Retrieve all versions of a given version series</description>
<url>/api/node/{store_type}/{store_id}/{id}/versions?filter={filter?}</url>
<url>/api/path/{store_type}/{store_id}/{id}/versions?filter={filter?}</url>
<authentication>user</authentication>
<format default="atomfeed">argument</format>
<cmis version="0.21"/>
</webscript>

View File

@@ -0,0 +1,25 @@
script:
{
// locate version series
// NOTE: version series is identified by noderef (as this is constant during lifetime of node)
var pathSegments = url.match.split("/");
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/"));
model.node = cmis.findNode(pathSegments[2], reference);
if (model.node === null || !model.node.isVersioned)
{
status.code = 404;
status.message = "Versions series " + pathSegments[2] + " " + reference.join("/") + " not found";
status.redirect = true;
break script;
}
// TODO: property filters
// retrieve versions
model.versions = model.node.versionHistory;
model.nodes = new Array(model.versions.length);
for (i = 0; i < model.versions.length; i++)
{
model.nodes[i] = model.versions[i].node;
}
}

View File

@@ -393,7 +393,7 @@
<bean id="webscripts.js.cmis" parent="baseJavaScriptExtension" class="org.alfresco.repo.cmis.rest.CMISScript">
<property name="extensionName"><value>cmis</value></property>
<property name="serviceRegistry" ref="ServiceRegistry" />
<property name="repository" ref="webscripts.repo" />
<property name="repository" ref="repositoryHelper" />
<property name="CMISService" ref="webscripts.cmis.service" />
<property name="paging" ref="webscripts.js.paging" />
</bean>
@@ -406,7 +406,7 @@
<property name="transactionHelper" ref="retryingTransactionHelper" />
<property name="tenantDeployerService" ref="tenantAdminService" />
<property name="nodeService" ref="nodeService" />
<property name="repository" ref="webscripts.repo" />
<property name="repository" ref="repositoryHelper" />
</bean>
<bean id="webscripts.cmis.description" class="org.alfresco.repo.cmis.rest.CMISDescription"/>

View File

@@ -3,6 +3,9 @@
<beans>
<!-- Import CXF support and CMIS WS -->
<import resource="classpath*:alfresco/cmis-ws-context.xml" />
<!-- Axis handler to validate the ticket sent with the web service request -->
<bean id="ticketCallbackHandler" class="org.alfresco.repo.webservice.axis.TicketCallbackHandler">
<property name="authenticationService">

View File

@@ -0,0 +1,257 @@
/*
* 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.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Validator;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.cmis.rest.xsd.CMISValidator;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Base CMIS Web Script Test
*
* @author davidc
*/
public class BaseCMISWebScriptTest extends BaseWebScriptTest
{
private CMISValidator cmisValidator = new CMISValidator();
private boolean argsAsHeaders = false;
/**
* Pass URL arguments as headers
*
* @param argsAsHeaders
*/
protected void setArgsAsHeaders(boolean argsAsHeaders)
{
this.argsAsHeaders = argsAsHeaders;
}
/**
* Determines if URL arguments are passed as headers
*
* @return
*/
protected boolean getArgsAsHeaders()
{
return argsAsHeaders;
}
/**
* Gets CMIS Validator
*
* @return CMIS Validator
*/
protected CMISValidator getCMISValidator()
{
return cmisValidator;
}
/**
* Gets CMIS App Validator
*
* @return CMIS App Validator
*
* @throws SAXException
* @throws IOException
*/
protected Validator getAppValidator()
throws IOException, SAXException
{
return getCMISValidator().getAppValidator();
}
/**
* Gets CMIS Atom Validator
*
* @return CMIS App Validator
*
* @throws SAXException
* @throws IOException
*/
protected Validator getAtomValidator()
throws IOException, SAXException
{
return null;
// TODO: Enable Atom Feed/Entry validator once up-to-date with 0.42
//return getCMISValidator().getCMISAtomValidator();
}
/**
* Asserts XML complies with specified Validator
*
* @param xml xml to assert
* @param validator validator to assert with
* @throws IOException
* @throws ParserConfigurationException
*/
protected void assertValidXML(String xml, Validator validator)
throws IOException, ParserConfigurationException
{
try
{
Document document = cmisValidator.getDocumentBuilder().parse(new InputSource(new StringReader(xml)));
validator.validate(new DOMSource(document));
}
catch (SAXException e)
{
fail(cmisValidator.toString(e, xml));
}
}
/**
* Load text from file specified by class path
*
* @param classPath XML file
* @return XML
* @throws IOException
*/
protected String loadString(String classPath)
throws IOException
{
InputStream input = getClass().getResourceAsStream(classPath);
if (input == null)
{
throw new IOException(classPath + " not found.");
}
InputStreamReader reader = new InputStreamReader(input);
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();
}
finally
{
reader.close();
writer.close();
}
return writer.toString();
}
/**
* Send Request to Test Web Script Server (as admin)
*
* @param req
* @param expectedStatus
* @return response
* @throws IOException
*/
protected Response sendRequest(Request req, int expectedStatus, Validator responseValidator)
throws IOException
{
return sendRequest(req, expectedStatus, responseValidator, null);
}
/**
* Send Request
*
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendRequest(Request req, int expectedStatus, Validator responseValidator, String asUser)
throws IOException
{
Response res = sendRequest(req, expectedStatus, asUser);
if (responseValidator != null)
{
try
{
// Validate response according to validator
String resXML = res.getContentAsString();
assertValidXML(resXML, responseValidator);
}
catch (ParserConfigurationException e)
{
throw new AlfrescoRuntimeException("Failed to validate", e);
}
}
return res;
}
/**
* Send Request to Test Web Script Server
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendRequest(Request req, int expectedStatus, String asUser)
throws IOException
{
if (argsAsHeaders)
{
Map<String, String> args = req.getArgs();
if (args != null)
{
Map<String, String> headers = req.getHeaders();
if (headers == null)
{
headers = new HashMap<String, String>();
}
for (Map.Entry<String, String> arg : args.entrySet())
{
headers.put("CMIS-" + arg.getKey(), arg.getValue());
}
req = new Request(req);
req.setArgs(null);
req.setHeaders(headers);
}
}
return super.sendRequest(req, expectedStatus, asUser);
}
}

View File

@@ -27,7 +27,7 @@ package org.alfresco.repo.cmis.rest;
import org.alfresco.repo.cmis.rest.CMISService.TypesFilter;
import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.repo.web.scripts.Repository;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.web.util.paging.Cursor;
import org.alfresco.repo.web.util.paging.Page;
import org.alfresco.repo.web.util.paging.PagedResults;

View File

@@ -30,6 +30,7 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
@@ -37,7 +38,6 @@ import org.alfresco.repo.tenant.TenantDeployer;
import org.alfresco.repo.tenant.TenantDeployerService;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.web.scripts.Repository;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -58,7 +58,7 @@ import org.springframework.context.ApplicationListener;
/**
* CMIS Navigation Service
* CMIS Service
*
* @author davidc
*/
@@ -90,7 +90,8 @@ public class CMISService implements ApplicationContextAware, ApplicationListener
private static final String LUCENE_QUERY_SHALLOW_FILES =
"+PARENT:\"${cm:parent}\" " +
"-TYPE:\"" + ContentModel.TYPE_SYSTEM_FOLDER + "\" " +
"+TYPE:\"" + ContentModel.TYPE_CONTENT + "\" ";
"+TYPE:\"" + ContentModel.TYPE_CONTENT + "\" " +
"-ASPECT:\"" + ContentModel.ASPECT_WORKING_COPY + "\"";
private static final String LUCENE_QUERY_CHECKEDOUT =
"+@cm\\:workingCopyOwner:${cm:username}";
@@ -382,16 +383,17 @@ public class CMISService implements ApplicationContextAware, ApplicationListener
}
}
ResultSet resultSet = searchService.query(params);
ResultSet resultSet = null;
try
{
resultSet = searchService.query(params);
List<NodeRef> results = resultSet.getNodeRefs();
NodeRef[] nodeRefs = new NodeRef[results.size()];
return results.toArray(nodeRefs);
}
finally
{
resultSet.close();
if (resultSet != null) resultSet.close();
}
}
@@ -421,16 +423,17 @@ public class CMISService implements ApplicationContextAware, ApplicationListener
params.setQuery(LUCENE_QUERY_SHALLOW_FILES);
}
ResultSet resultSet = searchService.query(params);
ResultSet resultSet = null;
try
{
resultSet = searchService.query(params);
List<NodeRef> results = resultSet.getNodeRefs();
NodeRef[] nodeRefs = new NodeRef[results.size()];
return results.toArray(nodeRefs);
}
finally
{
resultSet.close();
if (resultSet != null) resultSet.close();
}
}

View File

@@ -0,0 +1,767 @@
/*
* Copyright (C) 2005-2008 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.StringReader;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.util.GUID;
import org.alfresco.web.scripts.Format;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.alfresco.web.scripts.atom.AbderaService;
import org.alfresco.web.scripts.atom.AbderaServiceImpl;
import org.apache.abdera.ext.cmis.CMISConstants;
import org.apache.abdera.ext.cmis.CMISExtensionFactory;
import org.apache.abdera.ext.cmis.CMISProperties;
import org.apache.abdera.i18n.iri.IRI;
import org.apache.abdera.model.Collection;
import org.apache.abdera.model.Entry;
import org.apache.abdera.model.Feed;
import org.apache.abdera.model.Link;
import org.apache.abdera.model.Service;
/**
* CMIS API Test Harness
*
* @author davidc
*/
public class CMISTest extends BaseCMISWebScriptTest
{
private AbderaService abdera;
// test context
private String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository";
// cached responses
private static Service service = null;
private static Entry testsFolder = null;
private static Entry testRunFolder = null;
/**
* Sets the Repository "service" URL
*
* @param repositoryUrl repository service url
*/
public void setRepositoryUrl(String repositoryUrl)
{
this.repositoryUrl = repositoryUrl;
}
// TODO: checkout/checkin tests need to perform version property assertions
@Override
protected void setUp()
throws Exception
{
// setup client atom support
AbderaServiceImpl abderaImpl = new AbderaServiceImpl();
abderaImpl.afterPropertiesSet();
abderaImpl.registerExtensionFactory(new CMISExtensionFactory());
abdera = abderaImpl;
// setup user
setDefaultRunAs("admin");
super.setUp();
}
private Service getRepository()
throws Exception
{
if (service == null)
{
Response res = sendRequest(new GetRequest(repositoryUrl), 200, getAppValidator());
String xml = res.getContentAsString();
assertNotNull(xml);
assertTrue(xml.length() > 0);
//assertValidXML(xml, getCMISValidator().getAppValidator());
service = abdera.parseService(new StringReader(xml), null);
assertNotNull(service);
}
return service;
}
private IRI getRootCollection(Service service)
{
Collection root = service.getCollection("Main Repository", "root collection");
assertNotNull(root);
IRI rootHREF = root.getHref();
assertNotNull(rootHREF);
return rootHREF;
}
private IRI getCheckedOutCollection(Service service)
{
Collection root = service.getCollection("Main Repository", "checkedout collection");
assertNotNull(root);
IRI rootHREF = root.getHref();
assertNotNull(rootHREF);
return rootHREF;
}
private Entry createFolder(IRI parent, String name)
throws Exception
{
String createFolder = loadString("/cmis/rest/createfolder.atomentry.xml");
createFolder = createFolder.replace("${NAME}", name);
Response res = sendRequest(new PostRequest(parent.toString(), createFolder, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals(name, entry.getTitle());
assertEquals(name + " (summary)", entry.getSummary());
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("folder", props.getBaseType());
String testFolderHREF = (String)res.getHeader("Location");
assertNotNull(testFolderHREF);
return entry;
}
private Entry createDocument(IRI parent, String name)
throws Exception
{
String createFile = loadString("/cmis/rest/createdocument.atomentry.xml");
name = name + " " + System.currentTimeMillis();
createFile = createFile.replace("${NAME}", name);
Response res = sendRequest(new PostRequest(parent.toString(), createFile, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals(name, entry.getTitle());
assertEquals(name + " (summary)", entry.getSummary());
assertNotNull(entry.getContentSrc());
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("document", props.getBaseType());
String testFileHREF = (String)res.getHeader("Location");
assertNotNull(testFileHREF);
return entry;
}
private Entry createTestsFolder(IRI rootFolder)
throws Exception
{
// TODO: Convert to query
Feed children = getFeed(rootFolder);
for (Entry child : children.getEntries())
{
if (child.getTitle().equals("CMIS Tests"))
{
return child;
}
}
// not found, create it
return createFolder(rootFolder, "CMIS Tests");
}
private Entry createTestFolder(String name)
throws Exception
{
if (testRunFolder == null)
{
Service service = getRepository();
IRI rootFolderHREF = getRootCollection(service);
testsFolder = createTestsFolder(rootFolderHREF);
Link testsChildrenLink = testsFolder.getLink(CMISConstants.REL_CHILDREN);
testRunFolder = createFolder(testsChildrenLink.getHref(), "Test Run " + System.currentTimeMillis());
}
Link childrenLink = testRunFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry testFolder = createFolder(childrenLink.getHref(), name + " " + System.currentTimeMillis());
return testFolder;
}
private Entry getEntry(IRI href)
throws Exception
{
return getEntry(href, null);
}
private Entry getEntry(IRI href, Map<String, String> args)
throws Exception
{
Request get = new GetRequest(href.toString()).setArgs(args);
Response res = sendRequest(get, 200, getAtomValidator());
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals(getArgsAsHeaders() ? get.getUri() : get.getFullUri(), entry.getSelfLink().getHref().toString());
return entry;
}
private Feed getFeed(IRI href)
throws Exception
{
return getFeed(href, null);
}
private Feed getFeed(IRI href, Map<String, String> args)
throws Exception
{
Request get = new GetRequest(href.toString()).setArgs(args);
Response res = sendRequest(get, 200, getAtomValidator());
assertNotNull(res);
String xml = res.getContentAsString();
Feed feed = abdera.parseFeed(new StringReader(xml), null);
assertNotNull(feed);
assertEquals(getArgsAsHeaders() ? get.getUri() : get.getFullUri(), feed.getSelfLink().getHref().toString());
return feed;
}
public void testRepository()
throws Exception
{
Service service = getRepository();
IRI rootHREF = getRootCollection(service);
sendRequest(new GetRequest(rootHREF.toString()), 200, getAtomValidator());
}
public void testCreateDocument()
throws Exception
{
Entry testFolder = createTestFolder("testCreateDocument");
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");
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 testCreateFolder()
throws Exception
{
Entry testFolder = createTestFolder("testCreateFolder");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Feed children = getFeed(childrenLink.getHref());
assertNotNull(children);
int entriesBefore = children.getEntries().size();
Entry folder = createFolder(children.getSelfLink().getHref(), "testCreateFolder");
Feed feedFolderAfter = getFeed(childrenLink.getHref());
int entriesAfter = feedFolderAfter.getEntries().size();
assertEquals(entriesBefore +1, entriesAfter);
Entry entry = feedFolderAfter.getEntry(folder.getId().toString());
assertNotNull(entry);
}
public void testGet()
throws Exception
{
// get folder
Entry testFolder = createTestFolder("testGet");
assertNotNull(testFolder);
Entry testFolderFromGet = getEntry(testFolder.getSelfLink().getHref());
assertEquals(testFolder.getId(), testFolderFromGet.getId());
assertEquals(testFolder.getTitle(), testFolderFromGet.getTitle());
assertEquals(testFolder.getSummary(), testFolderFromGet.getSummary());
// get document
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry testDocument = createDocument(childrenLink.getHref(), "testGet");
assertNotNull(testDocument);
Entry testDocumentFromGet = getEntry(testDocument.getSelfLink().getHref());
assertEquals(testDocument.getId(), testDocumentFromGet.getId());
assertEquals(testDocument.getTitle(), testDocumentFromGet.getTitle());
assertEquals(testDocument.getSummary(), testDocumentFromGet.getSummary());
// get something that doesn't exist
Response res = sendRequest(new GetRequest(testDocument.getSelfLink().getHref().toString() + GUID.generate()), 404);
assertNotNull(res);
}
public void testChildren()
throws Exception
{
// create multiple children
Entry testFolder = createTestFolder("testChildren");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry document1 = createDocument(childrenLink.getHref(), "testChildren1");
assertNotNull(document1);
Entry document2 = createDocument(childrenLink.getHref(), "testChildren2");
assertNotNull(document2);
Entry document3 = createDocument(childrenLink.getHref(), "testChildren3");
assertNotNull(document3);
// checkout one of the children to ensure private working copy isn't included
Response documentRes = sendRequest(new GetRequest(document2.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
String documentXML = documentRes.getContentAsString();
assertNotNull(documentXML);
IRI checkedoutHREF = getCheckedOutCollection(service);
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes);
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
// get children, ensure they exist (but not private working copy)
Feed children = getFeed(childrenLink.getHref());
assertNotNull(children);
assertEquals(3, children.getEntries().size());
assertNotNull(children.getEntry(document1.getId().toString()));
assertNotNull(children.getEntry(document2.getId().toString()));
assertNotNull(children.getEntry(document3.getId().toString()));
assertNull(children.getEntry(pwc.getId().toString()));
// TODO: paging
}
public void testGetParent()
throws Exception
{
Entry testFolder = createTestFolder("testParent");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry childFolder = createFolder(childrenLink.getHref(), "testParentChild");
assertNotNull(childFolder);
Link parentLink = childFolder.getLink(CMISConstants.REL_PARENT);
assertNotNull(parentLink);
// ensure there is parent 'testParent'
Feed parent = getFeed(parentLink.getHref());
assertNotNull(parent);
assertEquals(1, parent.getEntries().size());
assertEquals(testFolder.getId(), parent.getEntries().get(0).getId());
// ensure there are ancestors 'testParent', "test run folder", "tests folder" and "root folder"
Map<String, String> args = new HashMap<String, String>();
args.put("returnToRoot", "true");
Feed parentsToRoot = getFeed(new IRI(parentLink.getHref().toString()), args);
assertNotNull(parentsToRoot);
assertEquals(4, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
}
public void testGetParents()
throws Exception
{
Entry testFolder = createTestFolder("testParents");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry childDocs = createDocument(childrenLink.getHref(), "testParentsChild");
assertNotNull(childDocs);
Link parentLink = childDocs.getLink(CMISConstants.REL_PARENTS);
assertNotNull(parentLink);
// ensure there is parent 'testParent'
Feed parent = getFeed(parentLink.getHref());
assertNotNull(parent);
assertEquals(1, parent.getEntries().size());
assertEquals(testFolder.getId(), parent.getEntries().get(0).getId());
// ensure there are ancestors 'testParent', "test run folder" and "root folder"
Map<String, String> args = new HashMap<String, String>();
args.put("returnToRoot", "true");
Feed parentsToRoot = getFeed(new IRI(parentLink.getHref().toString()), args);
assertNotNull(parentsToRoot);
assertEquals(4, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
assertEquals(testsFolder.getId(), parentsToRoot.getEntries().get(2).getId());
Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(3).getId());
}
public void testDelete()
throws Exception
{
// retrieve test folder for deletes
Entry testFolder = createTestFolder("testDelete");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed children = getFeed(childrenLink.getHref());
int entriesBefore = children.getEntries().size();
// create document for delete
Entry document = createDocument(childrenLink.getHref(), "testDelete");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
// ensure document has been created
Feed children2 = getFeed(childrenLink.getHref());
assertNotNull(children2);
int entriesAfterCreate = children2.getEntries().size();
assertEquals(entriesAfterCreate, entriesBefore +1);
// delete
Response deleteRes = sendRequest(new DeleteRequest(document.getSelfLink().getHref().toString()), 204);
assertNotNull(deleteRes);
// ensure document has been deleted
Feed children3 = getFeed(childrenLink.getHref());
assertNotNull(children3);
int entriesAfterDelete = children3.getEntries().size();
assertEquals(entriesBefore, entriesAfterDelete);
}
public void testUpdate()
throws Exception
{
// retrieve test folder for update
Entry testFolder = createTestFolder("testUpdate");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
// create document for update
Entry document = createDocument(childrenLink.getHref(), "testUpdate");
assertNotNull(document);
assertEquals("text/html", document.getContentMimeType().toString());
// update
String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml");
String guid = GUID.generate();
updateFile = updateFile.replace("${NAME}", guid);
Response res = sendRequest(new PutRequest(document.getSelfLink().getHref().toString(), updateFile, Format.ATOMENTRY.mimetype()), 200, getAtomValidator());
assertNotNull(res);
Entry updated = abdera.parseEntry(new StringReader(res.getContentAsString()), null);
// ensure update occurred
assertEquals(document.getId(), updated.getId());
assertEquals(document.getPublished(), updated.getPublished());
assertEquals("Updated Title " + guid, updated.getTitle());
assertEquals("text/plain", updated.getContentMimeType().toString());
Response contentRes = sendRequest(new GetRequest(updated.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, contentRes.getContentAsString());
}
public void testGetCheckedOut()
throws Exception
{
// retrieve test folder for checkouts
Entry testFolder = createTestFolder("testGetCheckedOut");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
assertNotNull(scope);
CMISProperties props = scope.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
assertNotNull(scopeId);
// retrieve checkouts within scope of test checkout folder
Service repository = getRepository();
assertNotNull(repository);
IRI checkedoutHREF = getCheckedOutCollection(service);
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(0, checkedout.getEntries().size());
}
public void testCheckout()
throws Exception
{
// retrieve test folder for checkouts
Entry testFolder = createTestFolder("testCheckout");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testCheckout");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
String documentXML = documentRes.getContentAsString();
assertNotNull(documentXML);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes);
// TODO: test private working copy properties
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
}
public void testCancelCheckout()
throws Exception
{
// retrieve test folder for checkouts
Entry testFolder = createTestFolder("testCancelCheckout");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testCancelCheckout");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes);
String pwcXml = pwcRes.getContentAsString();
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
// cancel checkout
Entry pwc = abdera.parseEntry(new StringReader(pwcXml), null);
assertNotNull(pwc);
Response cancelRes = sendRequest(new DeleteRequest(pwc.getSelfLink().getHref().toString()), 204);
assertNotNull(cancelRes);
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("folderId", scopeId2);
Feed checkedout2 = getFeed(new IRI(checkedoutHREF.toString()), args2);
assertNotNull(checkedout2);
assertEquals(0, checkedout2.getEntries().size());
}
public void testCheckIn()
throws Exception
{
// retrieve test folder for checkins
Entry testFolder = createTestFolder("testCheckIn");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testCheckin");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes);
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
assertNotNull(pwc);
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
// test update of private working copy
String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml");
String guid = GUID.generate();
updateFile = updateFile.replace("${NAME}", guid);
Response pwcUpdatedres = sendRequest(new PutRequest(pwc.getEditLink().getHref().toString(), updateFile, Format.ATOMENTRY.mimetype()), 200, getAtomValidator());
assertNotNull(pwcUpdatedres);
Entry updated = abdera.parseEntry(new StringReader(pwcUpdatedres.getContentAsString()), null);
// ensure update occurred
assertEquals(pwc.getId(), updated.getId());
assertEquals(pwc.getPublished(), updated.getPublished());
assertEquals("Updated Title " + guid, updated.getTitle());
assertEquals("text/plain", updated.getContentMimeType().toString());
Response pwcContentRes = sendRequest(new GetRequest(pwc.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, pwcContentRes.getContentAsString());
// checkin
String checkinFile = loadString("/cmis/rest/checkindocument.atomentry.xml");
String checkinUrl = pwc.getSelfLink().getHref().toString();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("checkinComment", guid);
Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
assertNotNull(checkinRes);
String checkinResXML = checkinRes.getContentAsString();
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args3 = new HashMap<String, String>();
args3.put("folderId", scopeId2);
Feed checkedout2 = getFeed(new IRI(checkedoutHREF.toString()), args3);
assertNotNull(checkedout2);
assertEquals(0, checkedout2.getEntries().size());
// test checked-in doc has new updates
Entry checkedIn = abdera.parseEntry(new StringReader(checkinResXML), null);
Entry updatedDoc = getEntry(checkedIn.getSelfLink().getHref());
// TODO: issue with updating name on PWC and it not reflecting on checked-in document
//assertEquals("Updated Title " + guid, updatedDoc.getTitle());
assertEquals("text/plain", updatedDoc.getContentMimeType().toString());
Response updatedContentRes = sendRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
}
public void testUpdateOnCheckIn()
throws Exception
{
// retrieve test folder for checkins
Entry testFolder = createTestFolder("testUpdateOnCheckIn");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testUpdateOnCheckIn");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes);
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
assertNotNull(pwc);
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
// checkin (with update)
String checkinFile = loadString("/cmis/rest/checkinandupdatedocument.atomentry.xml");
String guid = GUID.generate();
checkinFile = checkinFile.replace("${NAME}", guid);
String checkinUrl = pwc.getSelfLink().getHref().toString();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("checkinComment", guid);
Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
assertNotNull(checkinRes);
String checkinResXML = checkinRes.getContentAsString();
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args3 = new HashMap<String, String>();
args3.put("folderId", scopeId2);
Feed checkedout2 = getFeed(new IRI(checkedoutHREF.toString()), args3);
assertNotNull(checkedout2);
assertEquals(0, checkedout2.getEntries().size());
// test checked-in doc has new updates
Entry checkedIn = abdera.parseEntry(new StringReader(checkinResXML), null);
Entry updatedDoc = getEntry(checkedIn.getSelfLink().getHref());
// TODO: issue with updating name on PWC and it not reflecting on checked-in document
//assertEquals("Updated Title " + guid, updatedDoc.getTitle());
assertEquals("text/plain", updatedDoc.getContentMimeType().toString());
Response updatedContentRes = sendRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
}
public void testGetAllVersions()
throws Exception
{
int NUMBER_OF_VERSIONS = 3;
// retrieve test folder for checkins
Entry testFolder = createTestFolder("testGetAllVersions");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testGetAllVersions");
Response documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200, getAtomValidator());
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
IRI checkedoutHREF = getCheckedOutCollection(service);
for (int i = 0; i < NUMBER_OF_VERSIONS; i++)
{
// checkout
Response pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201, getAtomValidator());
assertNotNull(pwcRes);
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
assertNotNull(pwc);
// checkin
String checkinFile = loadString("/cmis/rest/checkinandupdatedocument.atomentry.xml");
checkinFile = checkinFile.replace("${NAME}", "checkin " + i);
String checkinUrl = pwc.getSelfLink().getHref().toString();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("checkinComment", "checkin " + i);
Response checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200, getAtomValidator());
assertNotNull(checkinRes);
}
// get all versions
Link allVersionsLink = document.getLink(CMISConstants.REL_ALLVERSIONS);
assertNotNull(allVersionsLink);
Feed allVersions = getFeed(allVersionsLink.getHref());
assertNotNull(allVersions);
assertEquals(NUMBER_OF_VERSIONS + 1 /** initial version */, allVersions.getEntries().size());
for (int i = 0; i < NUMBER_OF_VERSIONS; i++)
{
Link versionLink = allVersions.getEntries().get(i).getSelfLink();
assertNotNull(versionLink);
Entry version = getEntry(versionLink.getHref());
assertNotNull(version);
// TODO: issue with updating name on PWC and it not reflecting on checked-in document
//assertEquals("Update Title checkin " + i, version.getTitle());
Response versionContentRes = sendRequest(new GetRequest(version.getContentSrc().toString()), 200);
assertEquals("updated content checkin " + (NUMBER_OF_VERSIONS -1 - i), versionContentRes.getContentAsString());
// TODO: test version specific properties e.g. checkin comment
}
}
// public void testUnfiled()
// {
// }
}

View File

@@ -29,6 +29,8 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
@@ -36,6 +38,8 @@ import javax.xml.validation.Validator;
import org.alfresco.repo.cmis.rest.xsd.CMISValidator;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.springframework.mock.web.MockHttpServletResponse;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -49,7 +53,27 @@ import org.xml.sax.SAXException;
public class CMISWebScriptTest extends BaseWebScriptTest
{
private CMISValidator cmisValidator = new CMISValidator();
private boolean argsAsHeaders = false;
/**
* Pass URL arguments as headers
*
* @param argsAsHeaders
*/
protected void setArgsAsHeaders(boolean argsAsHeaders)
{
this.argsAsHeaders = argsAsHeaders;
}
/**
* Determines if URL arguments are passed as headers
*
* @return
*/
protected boolean getArgsAsHeaders()
{
return argsAsHeaders;
}
/**
* Gets CMIS Validator
@@ -121,4 +145,39 @@ public class CMISWebScriptTest extends BaseWebScriptTest
return writer.toString();
}
/**
* Send Request to Test Web Script Server
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected MockHttpServletResponse sendRequest(Request req, int expectedStatus, String asUser)
throws IOException
{
if (argsAsHeaders)
{
Map<String, String> args = req.getArgs();
if (args != null)
{
Map<String, String> headers = req.getHeaders();
if (headers == null)
{
headers = new HashMap<String, String>();
}
for (Map.Entry<String, String> arg : args.entrySet())
{
headers.put("CMIS-" + arg.getKey(), arg.getValue());
}
req = new Request(req);
req.setArgs(null);
req.setHeaders(headers);
}
}
return super.sendRequest(req, expectedStatus, asUser);
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2005-2008 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;
/**
* CMIS API Test Harness
*
* @author davidc
*/
public class CMISWithHeadersTest extends CMISTest
{
@Override
protected void setUp()
throws Exception
{
super.setUp();
setArgsAsHeaders(true);
}
}

View File

@@ -25,11 +25,19 @@
package org.alfresco.repo.cmis.rest;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.util.GUID;
import org.alfresco.web.scripts.Format;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.alfresco.web.scripts.atom.AbderaService;
import org.alfresco.web.scripts.atom.AbderaServiceImpl;
import org.apache.abdera.ext.cmis.CMISConstants;
import org.apache.abdera.ext.cmis.CMISExtensionFactory;
import org.apache.abdera.ext.cmis.CMISProperties;
import org.apache.abdera.i18n.iri.IRI;
@@ -51,7 +59,11 @@ public class TestCMIS extends CMISWebScriptTest
private AbderaService abdera;
private static Service service = null;
private static Entry testFolder = null;
private static Entry testRunFolder = null;
// TODO: checkout/checkin tests need to perform version property assertions
@Override
@@ -71,7 +83,7 @@ public class TestCMIS extends CMISWebScriptTest
{
if (service == null)
{
MockHttpServletResponse res = getRequest("/api/repository", 200, null);
MockHttpServletResponse res = sendRequest(new GetRequest("/api/repository"), 200);
String xml = res.getContentAsString();
assertNotNull(xml);
assertTrue(xml.length() > 0);
@@ -101,77 +113,96 @@ public class TestCMIS extends CMISWebScriptTest
return rootHREF;
}
private Entry getTestFolder()
private Entry createTestFolder(String name)
throws Exception
{
if (testFolder == null)
if (testRunFolder == null)
{
testFolder = createTestFolder();
Service service = getRepository();
IRI rootFolderHREF = getRootCollection(service);
testRunFolder = createFolder(rootFolderHREF, "CMIS Test Run " + System.currentTimeMillis());
}
Link childrenLink = testRunFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry testFolder = createFolder(childrenLink.getHref(), name + " " + System.currentTimeMillis());
return testFolder;
}
private Entry getEntry(IRI href)
throws Exception
{
MockHttpServletResponse res = getRequest(href.toString(), 200, "admin");
return getEntry(href, null);
}
private Entry getEntry(IRI href, Map<String, String> args)
throws Exception
{
Request get = new GetRequest(href.toString()).setArgs(args);
MockHttpServletResponse res = sendRequest(get, 200);
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals(href, entry.getSelfLink().getHref());
assertEquals(getArgsAsHeaders() ? get.getUri() : get.getFullUri(), entry.getSelfLink().getHref().toString());
return entry;
}
private Feed getFeed(IRI href)
throws Exception
{
MockHttpServletResponse res = getRequest(href.toString(), 200, "admin");
return getFeed(href, null);
}
private Feed getFeed(IRI href, Map<String, String> args)
throws Exception
{
Request get = new GetRequest(href.toString()).setArgs(args);
MockHttpServletResponse res = sendRequest(get, 200);
assertNotNull(res);
String xml = res.getContentAsString();
Feed feed = abdera.parseFeed(new StringReader(xml), null);
assertNotNull(feed);
assertEquals(href, feed.getSelfLink().getHref());
assertEquals(getArgsAsHeaders() ? get.getUri() : get.getFullUri(), feed.getSelfLink().getHref().toString());
return feed;
}
private Entry createTestFolder()
private Entry createFolder(IRI parent, String name)
throws Exception
{
Service service = getRepository();
IRI rootFolderHREF = getRootCollection(service);
String createFolder = loadString("/cmis/rest/createtestfolder.atomentry.xml");
String createFolder = loadString("/cmis/rest/createfolder.atomentry.xml");
String guid = GUID.generate();
createFolder = createFolder.replace("${NAME}", name);
createFolder = createFolder.replace("${GUID}", guid);
MockHttpServletResponse res = postRequest(rootFolderHREF.toString(), 201, createFolder, Format.ATOMENTRY.mimetype(), "admin");
MockHttpServletResponse res = sendRequest(new PostRequest(parent.toString(), createFolder, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals("CMIS Test Folder " + guid, entry.getTitle());
assertEquals("CMIS Test Folder " + guid + " Summary", entry.getSummary());
CMISProperties props = entry.getExtension(CMISExtensionFactory.PROPERTIES);
assertEquals("Title " + name + " " + guid, entry.getTitle());
assertEquals("Summary " + name + " " + guid, entry.getSummary());
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("folder", props.getBaseType());
String testFolderHREF = (String)res.getHeader("Location");
assertNotNull(testFolderHREF);
return entry;
}
private Entry createTestDocument(IRI parent)
private Entry createDocument(IRI parent, String name)
throws Exception
{
String createFile = loadString("/cmis/rest/createtestdocument.atomentry.xml");
String createFile = loadString("/cmis/rest/createdocument.atomentry.xml");
String guid = GUID.generate();
createFile = createFile.replace("${NAME}", name);
createFile = createFile.replace("${GUID}", guid);
MockHttpServletResponse res = postRequest(parent.toString(), 201, createFile, Format.ATOMENTRY.mimetype(), "admin");
MockHttpServletResponse res = sendRequest(new PostRequest(parent.toString(), createFile, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(res);
String xml = res.getContentAsString();
Entry entry = abdera.parseEntry(new StringReader(xml), null);
assertNotNull(entry);
assertEquals("Test Document " + guid, entry.getTitle());
assertEquals("Test Document " + guid + " Summary", entry.getSummary());
assertEquals("Title " + name + " " + guid, entry.getTitle());
assertEquals("Summary " + name + " " + guid, entry.getSummary());
assertNotNull(entry.getContentSrc());
CMISProperties props = entry.getExtension(CMISExtensionFactory.PROPERTIES);
CMISProperties props = entry.getExtension(CMISConstants.PROPERTIES);
assertEquals("document", props.getBaseType());
String testFileHREF = (String)res.getHeader("Location");
assertNotNull(testFileHREF);
@@ -183,25 +214,19 @@ public class TestCMIS extends CMISWebScriptTest
{
Service service = getRepository();
IRI rootHREF = getRootCollection(service);
getRequest(rootHREF.toString(), 200, "admin");
}
public void testCreateTestFolder()
throws Exception
{
createTestFolder();
sendRequest(new GetRequest(rootHREF.toString()), 200);
}
public void testCreateDocument()
throws Exception
{
Entry testFolder = getTestFolder();
Link childrenLink = testFolder.getLink("cmis-children");
Entry testFolder = createTestFolder("testCreateDocument");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Feed children = getFeed(childrenLink.getHref());
assertNotNull(children);
int entriesBefore = children.getEntries().size();
Entry document = createTestDocument(children.getSelfLink().getHref());
Entry document = createDocument(children.getSelfLink().getHref(), "testCreateDocument");
Feed feedFolderAfter = getFeed(childrenLink.getHref());
int entriesAfter = feedFolderAfter.getEntries().size();
assertEquals(entriesBefore +1, entriesAfter);
@@ -209,15 +234,212 @@ public class TestCMIS extends CMISWebScriptTest
assertNotNull(entry);
}
public void testCreateFolder()
throws Exception
{
Entry testFolder = createTestFolder("testCreateFolder");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Feed children = getFeed(childrenLink.getHref());
assertNotNull(children);
int entriesBefore = children.getEntries().size();
Entry folder = createFolder(children.getSelfLink().getHref(), "testCreateFolder");
Feed feedFolderAfter = getFeed(childrenLink.getHref());
int entriesAfter = feedFolderAfter.getEntries().size();
assertEquals(entriesBefore +1, entriesAfter);
Entry entry = feedFolderAfter.getEntry(folder.getId().toString());
assertNotNull(entry);
}
public void testGet()
throws Exception
{
// get folder
Entry testFolder = createTestFolder("testGet");
assertNotNull(testFolder);
Entry testFolderFromGet = getEntry(testFolder.getSelfLink().getHref());
assertEquals(testFolder.getId(), testFolderFromGet.getId());
assertEquals(testFolder.getTitle(), testFolderFromGet.getTitle());
assertEquals(testFolder.getSummary(), testFolderFromGet.getSummary());
// get document
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry testDocument = createDocument(childrenLink.getHref(), "testGet");
assertNotNull(testDocument);
Entry testDocumentFromGet = getEntry(testDocument.getSelfLink().getHref());
assertEquals(testDocument.getId(), testDocumentFromGet.getId());
assertEquals(testDocument.getTitle(), testDocumentFromGet.getTitle());
assertEquals(testDocument.getSummary(), testDocumentFromGet.getSummary());
// get something that doesn't exist
MockHttpServletResponse res = sendRequest(new GetRequest("/api/node/workspace/SpacesStore/" + GUID.generate()), 404);
assertNotNull(res);
}
public void testChildren()
throws Exception
{
// create multiple children
Entry testFolder = createTestFolder("testChildren");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry document1 = createDocument(childrenLink.getHref(), "testChildren1");
assertNotNull(document1);
Entry document2 = createDocument(childrenLink.getHref(), "testChildren2");
assertNotNull(document2);
Entry document3 = createDocument(childrenLink.getHref(), "testChildren3");
assertNotNull(document3);
// checkout one of the children to ensure private working copy isn't included
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document2.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
String documentXML = documentRes.getContentAsString();
assertNotNull(documentXML);
IRI checkedoutHREF = getCheckedOutCollection(service);
MockHttpServletResponse pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(pwcRes);
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
// get children, ensure they exist (but not private working copy)
Feed children = getFeed(childrenLink.getHref());
assertNotNull(children);
assertEquals(3, children.getEntries().size());
assertNotNull(children.getEntry(document1.getId().toString()));
assertNotNull(children.getEntry(document2.getId().toString()));
assertNotNull(children.getEntry(document3.getId().toString()));
assertNull(children.getEntry(pwc.getId().toString()));
// TODO: paging
}
public void testGetParent()
throws Exception
{
Entry testFolder = createTestFolder("testParent");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry childFolder = createFolder(childrenLink.getHref(), "testParentChild");
assertNotNull(childFolder);
Link parentLink = childFolder.getLink(CMISConstants.REL_PARENT);
assertNotNull(parentLink);
// ensure there is parent 'testParent'
Feed parent = getFeed(parentLink.getHref());
assertNotNull(parent);
assertEquals(1, parent.getEntries().size());
assertEquals(testFolder.getId(), parent.getEntries().get(0).getId());
// ensure there are ancestors 'testParent', "test run folder" and "root folder"
Map<String, String> args = new HashMap<String, String>();
args.put("returnToRoot", "true");
Feed parentsToRoot = getFeed(new IRI(parentLink.getHref().toString()), args);
assertNotNull(parentsToRoot);
assertEquals(3, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(2).getId());
}
public void testGetParents()
throws Exception
{
Entry testFolder = createTestFolder("testParents");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
assertNotNull(childrenLink);
Entry childDocs = createDocument(childrenLink.getHref(), "testParentsChild");
assertNotNull(childDocs);
Link parentLink = childDocs.getLink(CMISConstants.REL_PARENTS);
assertNotNull(parentLink);
// ensure there is parent 'testParent'
Feed parent = getFeed(parentLink.getHref());
assertNotNull(parent);
assertEquals(1, parent.getEntries().size());
assertEquals(testFolder.getId(), parent.getEntries().get(0).getId());
// ensure there are ancestors 'testParent', "test run folder" and "root folder"
Map<String, String> args = new HashMap<String, String>();
args.put("returnToRoot", "true");
Feed parentsToRoot = getFeed(new IRI(parentLink.getHref().toString()), args);
assertNotNull(parentsToRoot);
assertEquals(3, parentsToRoot.getEntries().size());
assertEquals(testFolder.getId(), parentsToRoot.getEntries().get(0).getId());
assertEquals(testRunFolder.getId(), parentsToRoot.getEntries().get(1).getId());
Feed root = getFeed(getRootCollection(getRepository()));
assertEquals(root.getId(), parentsToRoot.getEntries().get(2).getId());
}
public void testDelete()
throws Exception
{
// retrieve test folder for deletes
Entry testFolder = createTestFolder("testDelete");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed children = getFeed(childrenLink.getHref());
int entriesBefore = children.getEntries().size();
// create document for delete
Entry document = createDocument(childrenLink.getHref(), "testDelete");
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
// ensure document has been created
Feed children2 = getFeed(childrenLink.getHref());
assertNotNull(children2);
int entriesAfterCreate = children2.getEntries().size();
assertEquals(entriesAfterCreate, entriesBefore +1);
// delete
MockHttpServletResponse deleteRes = sendRequest(new DeleteRequest(document.getSelfLink().getHref().toString()), 204);
assertNotNull(deleteRes);
// ensure document has been deleted
Feed children3 = getFeed(childrenLink.getHref());
assertNotNull(children3);
int entriesAfterDelete = children3.getEntries().size();
assertEquals(entriesBefore, entriesAfterDelete);
}
public void testUpdate()
throws Exception
{
// retrieve test folder for update
Entry testFolder = createTestFolder("testUpdate");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
// create document for update
Entry document = createDocument(childrenLink.getHref(), "testUpdate");
assertNotNull(document);
assertEquals("text/html", document.getContentMimeType().toString());
// update
String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml");
String guid = GUID.generate();
updateFile = updateFile.replace("${GUID}", guid);
MockHttpServletResponse res = sendRequest(new PutRequest(document.getSelfLink().getHref().toString(), updateFile, Format.ATOMENTRY.mimetype()), 200);
assertNotNull(res);
Entry updated = abdera.parseEntry(new StringReader(res.getContentAsString()), null);
// ensure update occurred
assertEquals(document.getId(), updated.getId());
assertEquals(document.getPublished(), updated.getPublished());
assertEquals("Updated Title " + guid, updated.getTitle());
assertEquals("text/plain", updated.getContentMimeType().toString());
MockHttpServletResponse contentRes = sendRequest(new GetRequest(updated.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, contentRes.getContentAsString());
}
public void testGetCheckedOut()
throws Exception
{
// retrieve test folder for checkouts
Entry testFolder = getTestFolder();
Link childrenLink = testFolder.getLink("cmis-children");
Entry testFolder = createTestFolder("testGetCheckedOut");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
assertNotNull(scope);
CMISProperties props = scope.getExtension(CMISExtensionFactory.PROPERTIES);
CMISProperties props = scope.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
assertNotNull(scopeId);
@@ -225,7 +447,9 @@ public class TestCMIS extends CMISWebScriptTest
Service repository = getRepository();
assertNotNull(repository);
IRI checkedoutHREF = getCheckedOutCollection(service);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString() + "?folderId=" + scopeId));
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(0, checkedout.getEntries().size());
}
@@ -234,29 +458,154 @@ public class TestCMIS extends CMISWebScriptTest
throws Exception
{
// retrieve test folder for checkouts
Entry testFolder = getTestFolder();
Link childrenLink = testFolder.getLink("cmis-children");
Entry testFolder = createTestFolder("testCheckout");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createTestDocument(scope.getSelfLink().getHref());
MockHttpServletResponse documentRes = getRequest(document.getSelfLink().getHref().toString(), 200, "admin");
Entry document = createDocument(scope.getSelfLink().getHref(), "testCheckout");
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
String documentXML = documentRes.getContentAsString();
assertNotNull(documentXML);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
MockHttpServletResponse pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), documentXML, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(pwcRes);
// TODO: test private working copy properties
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
}
public void testCancelCheckout()
throws Exception
{
// retrieve test folder for checkouts
Entry testFolder = createTestFolder("testCancelCheckout");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testCancelCheckout");
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
MockHttpServletResponse checkoutRes = postRequest(checkedoutHREF.toString(), 201, xml, Format.ATOMENTRY.mimetype(), "admin");
assertNotNull(checkoutRes);
// TODO: test private working copy properties
MockHttpServletResponse pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(pwcRes);
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISExtensionFactory.PROPERTIES);
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString() + "?folderId=" + scopeId));
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
// cancel checkout
String pwcXml = pwcRes.getContentAsString();
Entry pwc = abdera.parseEntry(new StringReader(pwcXml), null);
assertNotNull(pwc);
MockHttpServletResponse cancelRes = sendRequest(new DeleteRequest(pwc.getSelfLink().getHref().toString()), 204);
assertNotNull(cancelRes);
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("folderId", scopeId2);
Feed checkedout2 = getFeed(new IRI(checkedoutHREF.toString()), args2);
assertNotNull(checkedout2);
assertEquals(0, checkedout2.getEntries().size());
}
public void testCheckIn()
throws Exception
{
// retrieve test folder for checkins
Entry testFolder = createTestFolder("testCheckIn");
Link childrenLink = testFolder.getLink(CMISConstants.REL_CHILDREN);
Feed scope = getFeed(childrenLink.getHref());
// create document for checkout
Entry document = createDocument(scope.getSelfLink().getHref(), "testCheckin");
MockHttpServletResponse documentRes = sendRequest(new GetRequest(document.getSelfLink().getHref().toString()), 200);
assertNotNull(documentRes);
String xml = documentRes.getContentAsString();
assertNotNull(xml);
// checkout
IRI checkedoutHREF = getCheckedOutCollection(service);
MockHttpServletResponse pwcRes = sendRequest(new PostRequest(checkedoutHREF.toString(), xml, Format.ATOMENTRY.mimetype()), 201);
assertNotNull(pwcRes);
Entry pwc = abdera.parseEntry(new StringReader(pwcRes.getContentAsString()), null);
assertNotNull(pwc);
// test getCheckedOut is updated
CMISProperties props = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId = props.getObjectId();
Map<String, String> args = new HashMap<String, String>();
args.put("folderId", scopeId);
Feed checkedout = getFeed(new IRI(checkedoutHREF.toString()), args);
assertNotNull(checkedout);
assertEquals(1, checkedout.getEntries().size());
// test update of private working copy
String updateFile = loadString("/cmis/rest/updatedocument.atomentry.xml");
String guid = GUID.generate();
updateFile = updateFile.replace("${GUID}", guid);
MockHttpServletResponse pwcUpdatedres = sendRequest(new PutRequest(pwc.getEditLink().getHref().toString(), updateFile, Format.ATOMENTRY.mimetype()), 200);
assertNotNull(pwcUpdatedres);
Entry updated = abdera.parseEntry(new StringReader(pwcUpdatedres.getContentAsString()), null);
// ensure update occurred
assertEquals(pwc.getId(), updated.getId());
assertEquals(pwc.getPublished(), updated.getPublished());
assertEquals("Updated Title " + guid, updated.getTitle());
assertEquals("text/plain", updated.getContentMimeType().toString());
MockHttpServletResponse pwcContentRes = sendRequest(new GetRequest(pwc.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, pwcContentRes.getContentAsString());
// checkin
String checkinFile = loadString("/cmis/rest/checkindocument.atomentry.xml");
String checkinUrl = pwc.getSelfLink().getHref().toString();
Map<String, String> args2 = new HashMap<String, String>();
args2.put("checkinComment", guid);
MockHttpServletResponse checkinRes = sendRequest(new PutRequest(checkinUrl, checkinFile, Format.ATOMENTRY.mimetype()).setArgs(args2), 200);
assertNotNull(checkinRes);
// test getCheckedOut is updated
CMISProperties props2 = testFolder.getExtension(CMISConstants.PROPERTIES);
String scopeId2 = props2.getObjectId();
Map<String, String> args3 = new HashMap<String, String>();
args3.put("folderId", scopeId2);
Feed checkedout2 = getFeed(new IRI(checkedoutHREF.toString()), args3);
assertNotNull(checkedout2);
assertEquals(0, checkedout2.getEntries().size());
// test checked-in doc has new updates
Entry checkedIn = abdera.parseEntry(new StringReader(checkinRes.getContentAsString()), null);
Entry updatedDoc = getEntry(checkedIn.getSelfLink().getHref());
// TODO: issue with updating name on PWC and it not reflecting on checked-in document
//assertEquals("Updated Title " + guid, updatedDoc.getTitle());
assertEquals("text/plain", updatedDoc.getContentMimeType().toString());
MockHttpServletResponse updatedContentRes = sendRequest(new GetRequest(updatedDoc.getContentSrc().toString()), 200);
assertEquals("updated content " + guid, updatedContentRes.getContentAsString());
}
// public void testUnfiled()
// {
// }
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2005-2008 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;
/**
* CMIS API Test Harness
*
* @author davidc
*/
public class TestCMISWithHeaders extends TestCMIS
{
@Override
protected void setUp()
throws Exception
{
super.setUp();
setArgsAsHeaders(true);
}
}

View File

@@ -0,0 +1,95 @@
/*
* Copyright (C) 2005-2008 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 junit.framework.TestSuite;
import junit.textui.TestRunner;
/**
* CMIS API Test Harness
*
* @author davidc
*/
public class TestRemoteCMIS extends CMISTest
{
// remote CMIS server
private static String repositoryUrl = "http://localhost:8080/alfresco/service/api/repository";
private static String username = "admin";
private static String password = "admin";
private static boolean argsAsHeaders = false;
@Override
protected void setUp() throws Exception
{
if (repositoryUrl != null)
{
setRepositoryUrl(repositoryUrl);
RemoteServer server = new RemoteServer();
server.username = username;
server.password = password;
setRemoteServer(server);
}
setArgsAsHeaders(argsAsHeaders);
super.setUp();
}
/**
* Execute Unit Tests as client to remote CMIS Server
*
* args[0] = serverUrl
* args[1] = username/password
*
* @param args args
*/
public static void main(String[] args)
{
if (args.length > 0)
{
repositoryUrl = args[0];
}
if (args.length > 1)
{
String[] credentials = args[1].split("/");
username = credentials[0];
if (credentials.length > 1)
{
password = credentials[1];
}
}
// execute cmis tests with url arguments
TestRunner.run(new TestSuite(TestRemoteCMIS.class));
// execute cmis tests with headers
argsAsHeaders = true;
TestRunner.run(new TestSuite(TestRemoteCMIS.class));
}
}

View File

@@ -22,6 +22,7 @@
<xs:sequence>
<xs:element ref="atom:author" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element ref="app:workspace" minOccurs="1" maxOccurs="unbounded"></xs:element>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax" namespace="##other"/>
</xs:sequence>
</xs:complexType>

View File

@@ -11,11 +11,14 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:cmis="http://www.cmis.org/2008/05"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1">
<xs:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="xhtml1-strict.xsd"/>
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
<xs:import namespace="http://www.cmis.org/2008/05" schemaLocation="CMIS-REST.xsd"/>
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/xml.xsd" />
<xs:import namespace="http://www.cmis.org/2008/05"
schemaLocation="CMIS-REST.xsd" />
<!-- Common attributes -->
@@ -38,7 +41,8 @@
</xs:attributeGroup>
<xs:group name="atomXHTMLTextConstruct">
<xs:sequence>
<xs:element ref="xhtml:div"/>
<!-- xs:element ref="xhtml:div"/> -->
<xs:element name="xhtmldivhere" type="xs:string" />
</xs:sequence>
</xs:group>
<xs:attributeGroup name="atomXHTMLTextConstruct">
@@ -66,12 +70,12 @@
</xs:complexType>
<!-- Person Construct -->
<xs:complexType name="atomPersonConstruct">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="atom:name"/>
<xs:element ref="atom:uri"/>
<xs:element ref="atom:email"/>
<xs:group ref="atom:extensionElement"/>
</xs:choice>
<xs:sequence>
<xs:element ref="atom:name" minOccurs="0" maxOccurs="1"/>
<xs:element ref="atom:uri" minOccurs="0" maxOccurs="1"/>
<xs:element ref="atom:email" minOccurs="0" maxOccurs="1"/>
<xs:group ref="atom:extensionElement" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
<xs:element name="name" type="xs:string" />
@@ -86,31 +90,44 @@
</xs:simpleContent>
</xs:complexType>
<!-- atom:feed -->
<xs:element name="feed">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="atom:author"/>
<xs:element ref="atom:category"/>
<xs:element ref="atom:contributor"/>
<xs:element ref="atom:generator"/>
<xs:element ref="atom:icon"/>
<xs:element ref="atom:id"/>
<xs:element ref="atom:link"/>
<xs:element ref="atom:logo"/>
<xs:element ref="atom:rights"/>
<xs:element ref="atom:subtitle"/>
<xs:element ref="atom:title"/>
<xs:element ref="atom:updated"/>
<xs:group ref="atom:extensionElement"/>
</xs:choice>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="atom:entry"/>
<xs:element name="feed" type="atom:feedType"></xs:element>
<xs:element minOccurs="0" maxOccurs="1" ref="cmis:hasMoreItems"/>
<xs:complexType name="feedType">
<xs:sequence>
<xs:element ref="atom:author" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:category" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:contributor" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:generator" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:icon" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:id" minOccurs="1" maxOccurs="1" />
<xs:element ref="atom:link" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:logo" minOccurs="0" maxOccurs="1" />
<xs:element ref="atom:rights" minOccurs="0" maxOccurs="1" />
<xs:element ref="atom:subtitle" minOccurs="0" maxOccurs="1" />
<xs:element ref="atom:title" minOccurs="1" maxOccurs="1" />
<xs:element ref="atom:updated" minOccurs="1" maxOccurs="1" />
<xs:element minOccurs="0" maxOccurs="unbounded"
ref="atom:entry" />
<!-- Start Atom's extension here -->
<xs:element minOccurs="0" maxOccurs="unbounded"
ref="cmis:type" />
<xs:element ref="cmis:hasMoreItems" minOccurs="1"
maxOccurs="1" />
<!-- original atom extension element -->
<xs:group ref="atom:extensionElement" />
</xs:sequence>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
</xs:complexType>
</xs:element>
<!-- atom:entry -->
<xs:element name="entry" type="atom:entryType">
@@ -118,32 +135,49 @@
<xs:complexType name="entryType">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="atom:author" />
<xs:element ref="atom:category" />
<xs:element ref="atom:content" />
<xs:element ref="atom:contributor" />
<xs:element ref="atom:id" />
<xs:element ref="atom:link" />
<xs:element ref="atom:published" />
<xs:element ref="atom:rights" />
<xs:element ref="atom:source" />
<xs:element ref="atom:summary" />
<xs:element ref="atom:title" />
<xs:element ref="atom:updated" />
<xs:group ref="atom:extensionElement" />
<xs:element ref="atom:uri"></xs:element>
</xs:choice>
<xs:sequence>
<xs:element ref="cmis:properties" minOccurs="0" maxOccurs="1"/>
<xs:element ref="atom:author" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:category" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:content" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:contributor" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:id" minOccurs="1" maxOccurs="1" />
<xs:element ref="atom:link" minOccurs="0"
maxOccurs="unbounded" />
<xs:element ref="atom:published" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:rights" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:source" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:summary" minOccurs="0"
maxOccurs="1" />
<xs:element ref="atom:title" minOccurs="1"
maxOccurs="1" />
<xs:element ref="atom:updated" minOccurs="1"
maxOccurs="1" />
<!-- CMIS AllowableActions, optional for CMIS -->
<xs:element ref="cmis:allowableActions" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<!-- CMIS Properties, optional if not CMIS -->
<xs:element ref="cmis:properties" minOccurs="1" maxOccurs="1" />
<!-- This is necessary for nested entries such as descendants -->
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element ref="atom:entry" />
</xs:choice>
<xs:element ref="atom:entry" minOccurs="0" maxOccurs="unbounded" />
<!-- Normal ATOM extension element -->
<xs:group ref="atom:extensionElement" />
</xs:sequence>
</xs:sequence>
<xs:attributeGroup ref="atom:atomCommonAttributes" />
@@ -163,7 +197,8 @@
</xs:attributeGroup>
<xs:group name="atomInlineOtherConstruct">
<xs:sequence>
<xs:group minOccurs="0" maxOccurs="unbounded" ref="atom:anyElement"/>
<xs:group minOccurs="0" maxOccurs="unbounded"
ref="atom:anyElement" />
</xs:sequence>
</xs:group>
<xs:attributeGroup name="atomInlineOtherConstruct">
@@ -198,7 +233,8 @@
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:union memberTypes="atom:atomMediaType">
<xs:union
memberTypes="atom:atomMediaType">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="xhtml" />
@@ -260,9 +296,10 @@
<xs:element name="link">
<xs:annotation>
<xs:documentation>
The "atom:link" element defines a reference from an entry
or feed to a Web resource. This specification assigns no
meaning to the content (if any) of this element.
The "atom:link" element defines a reference from an
entry or feed to a Web resource. This specification
assigns no meaning to the content (if any) of this
element.
</xs:documentation>
</xs:annotation>
<xs:complexType>
@@ -270,8 +307,7 @@
<xs:extension base="atom:undefinedContent">
<xs:attributeGroup ref="atom:atomCommonAttributes" />
<xs:attribute name="href" use="required" />
<xs:attribute name="rel">
</xs:attribute>
<xs:attribute name="rel"></xs:attribute>
<xs:attribute name="type" type="atom:atomMediaType" />
<xs:attribute name="hreflang"
type="atom:atomLanguageTag" />
@@ -289,7 +325,8 @@
<xs:element name="source">
<xs:annotation>
<xs:documentation>
atom:source is used to preserve metadata of a feed when an entry is copied from a feed to another feed.
atom:source is used to preserve metadata of a feed when
an entry is copied from a feed to another feed.
</xs:documentation>
</xs:annotation>
<xs:complexType>
@@ -319,8 +356,8 @@
<xs:element name="title" type="atom:atomTextConstruct">
<xs:annotation>
<xs:documentation>
The "atom:title" element is a Text construct that conveys a human-
readable title for an entry or feed.
The "atom:title" element is a Text construct that
conveys a human- readable title for an entry or feed.
atomTitle = element atom:title { atomTextConstruct }.
</xs:documentation>
</xs:annotation>
@@ -329,12 +366,14 @@
<xs:element name="updated" type="atom:atomDateConstruct">
<xs:annotation>
<xs:documentation>
The "atom:updated" element is a Date construct indicating the most
recent instant in time when an entry or feed was modified in a way
the publisher considers significant. Therefore, not all
modifications necessarily result in a changed atom:updated value.
atomUpdated = element atom:updated { atomDateConstruct }.
Publishers MAY change the value of this element over time.
The "atom:updated" element is a Date construct
indicating the most recent instant in time when an entry
or feed was modified in a way the publisher considers
significant. Therefore, not all modifications
necessarily result in a changed atom:updated value.
atomUpdated = element atom:updated { atomDateConstruct
}. Publishers MAY change the value of this element over
time.
</xs:documentation>
</xs:annotation>
</xs:element>
@@ -369,70 +408,51 @@
</xs:simpleType>
<!-- Simple Extension -->
<xs:group name="extensionElement">
<xs:choice>
<xs:any namespace="##other" processContents="skip"/>
<xs:any namespace="##local" processContents="skip"/>
</xs:choice>
<xs:sequence>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jaxb:property name='anyOther' />
</xs:appinfo>
</xs:annotation>
</xs:any>
<xs:any namespace="##local" processContents="lax"
minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jaxb:property name='anyLocal' />
</xs:appinfo>
</xs:annotation>
</xs:any>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="undefinedAttribute">
<xs:anyAttribute namespace="##other" processContents="skip"/>
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:attributeGroup>
<xs:complexType name="undefinedContent" mixed="true">
<xs:group minOccurs="0" maxOccurs="unbounded" ref="atom:anyForeignElement"/>
<xs:group minOccurs="0" maxOccurs="unbounded"
ref="atom:anyForeignElement" />
</xs:complexType>
<xs:group name="anyElement">
<xs:sequence>
<xs:any processContents="skip"/>
<xs:any processContents="lax" />
</xs:sequence>
</xs:group>
<xs:group name="anyForeignElement">
<xs:choice>
<xs:any namespace="##other" processContents="skip"/>
<xs:any namespace="##local" processContents="skip"/>
<xs:any namespace="##other" processContents="lax" />
<xs:any namespace="##local" processContents="lax" />
</xs:choice>
</xs:group>
<!-- XHTML -->
<xs:group name="anyXHTML">
<xs:sequence>
<xs:any namespace="http://www.w3.org/1999/xhtml" processContents="skip"/>
<xs:any namespace="http://www.w3.org/1999/xhtml"
processContents="lax" />
</xs:sequence>
</xs:group>
<xs:element name="service" type="atom:atomServiceType"></xs:element>
<xs:complexType name="atomServiceType">
<xs:sequence>
<xs:element ref="atom:author"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="workspace" type="atom:atomWorkspaceType"></xs:element>
<xs:complexType name="atomWorkspaceType">
<xs:sequence>
<xs:element ref="atom:title"></xs:element>
<xs:element ref="cmis:repositoryInfo"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="collection" type="xs:string"></xs:element>
<xs:complexType name="atomCollectionType">
<xs:sequence>
<xs:element ref="atom:title"></xs:element>
</xs:sequence>
<xs:attribute ref="cmis:collectionType"></xs:attribute>
<xs:attribute ref="cmis:id"></xs:attribute>
</xs:complexType>
</xs:schema>
<!-- EOF -->

File diff suppressed because it is too large Load Diff

View File

@@ -30,13 +30,8 @@ import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.XMLConstants;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import junit.framework.TestCase;
@@ -51,7 +46,7 @@ import org.xml.sax.SAXException;
*
* @author davidc
*/
public class TestXSDs extends TestCase
public class CMISSchemaTest extends TestCase
{
private CMISValidator cmisValidator = new CMISValidator();
@@ -127,11 +122,25 @@ public class TestXSDs extends TestCase
// assertValidXML(xml, schema.newValidator());
// }
public void testService()
public void testAllowableActions()
throws Exception
{
String xml = getXML("Example-Service.xml");
assertValidXML(xml, cmisValidator.getAppValidator());
String xml = getXML("Example-AllowableActions.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testDocumentEntry()
throws Exception
{
String xml = getXML("Example-DocumentEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testDocumentPWCEntry()
throws Exception
{
String xml = getXML("Example-DocumentPWCEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testFolderChildren()
@@ -141,4 +150,53 @@ public class TestXSDs extends TestCase
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testFolderDescendants()
throws Exception
{
String xml = getXML("Example-FolderDescendants.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testFolderEntry()
throws Exception
{
String xml = getXML("Example-FolderEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testPolicyEntry()
throws Exception
{
String xml = getXML("Example-PolicyEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testQuery()
throws Exception
{
String xml = getXML("Example-Query.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testRelationshipEntry()
throws Exception
{
String xml = getXML("Example-RelationshipEntry.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
public void testService()
throws Exception
{
String xml = getXML("Example-Service.xml");
assertValidXML(xml, cmisValidator.getAppValidator());
}
public void testType()
throws Exception
{
String xml = getXML("Example-Type.xml");
assertValidXML(xml, cmisValidator.getCMISAtomValidator());
}
}

View File

@@ -3,7 +3,7 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../ATOM4CMIS.xsd http://www.cmis.org/2008/05 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<!-- all -->
<cmis:canDelete>true</cmis:canDelete>

View File

@@ -5,26 +5,23 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../ATOM4CMIS.xsd http://www.cmis.org/2008/05 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Document Entry example</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit-media"
@@ -50,44 +47,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry" />
<!-- atom:content -->
<atom:content src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry example</atom:title>
<cmis:properties>
<cmis:objectId>docid1</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<cmis:isCheckedOut>false</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>true</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>true</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<cmis:isVersionSeriesCheckedOut>
false
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy></cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID></cmis:versionSeriesCheckedOutID>
<cmis:checkinComment>
This is the initial checkin comment
</cmis:checkinComment>
<cmis:versionLabel>1.0</cmis:versionLabel>
<cmis:contentStreamLength>70</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -109,4 +79,36 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyBoolean cmis:name="isCheckedOut">false</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">true</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">true</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">true</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">false</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isVersionSeriesCheckedOut">false</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">docid1</cmis:propertyID>
<cmis:propertyID cmis:name="versionSeriesCheckedOutID"></cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">70</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">email</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">document</cmis:propertyString>
<cmis:propertyString cmis:name="versionSeriesCheckedOutBy"></cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">This is the initial checkin comment</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">1.0</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">text/plain</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">foo.txt</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>

View File

@@ -5,26 +5,23 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../ATOM4CMIS.xsd http://www.cmis.org/2008/05 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Document Entry example PWC</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<!-- lastModifiedDate -->
<atom:updated>2007-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit-media"
@@ -50,50 +47,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry" />
<!-- atom:content -->
<atom:content src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry example</atom:title>
<cmis:properties>
<cmis:objectId>docid1pwc</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<!-- PWC -->
<cmis:isCheckedOut>true</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>false</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>false</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<!-- PWC -->
<cmis:isVersionSeriesCheckedOut>
true
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy>Al Brown</cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID>docid1pwc</cmis:versionSeriesCheckedOutID>
<cmis:checkinComment></cmis:checkinComment>
<!-- PWC -->
<cmis:versionLabel>1.1</cmis:versionLabel>
<cmis:contentStreamLength>70</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -104,7 +68,7 @@
<cmis:canMove>true</cmis:canMove>
<cmis:canDeleteVersion>true</cmis:canDeleteVersion>
<cmis:canDeleteContent>true</cmis:canDeleteContent>
<cmis:canCheckout>false</cmis:canCheckout>
<cmis:canCheckout>true</cmis:canCheckout>
<cmis:canCancelCheckout>true</cmis:canCancelCheckout>
<cmis:canCheckin>true</cmis:canCheckin>
<cmis:canSetContent>true</cmis:canSetContent>
@@ -115,4 +79,47 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<!-- PWC -->
<cmis:propertyBoolean cmis:name="isCheckedOut">true</cmis:propertyBoolean>
<!-- PWC -->
<cmis:propertyBoolean cmis:name="isLatestVersion">true</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">false</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">false</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">false</cmis:propertyBoolean>
<!-- PWC -->
<cmis:propertyBoolean cmis:name="isVersionSeriesCheckedOut">true</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2007-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2007-12-31T12:00:00</cmis:propertyDateTime>
<!-- PWC -->
<cmis:propertyID cmis:name="objectId">docid1pwc</cmis:propertyID>
<!-- PWC -->
<cmis:propertyID cmis:name="versionSeriesCheckedOutID">docidpwc</cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">70</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">email</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">document</cmis:propertyString>
<!-- PWC -->
<cmis:propertyString cmis:name="versionSeriesCheckedOutBy">Al Brown</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">This is the initial checkin comment</cmis:propertyString>
<!-- PWC -->
<cmis:propertyString cmis:name="versionLabel">1.1</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">text/plain</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">foo.txt</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>

View File

@@ -5,23 +5,23 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../ATOM4CMIS.xsd http://www.cmis.org/2008/05 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<!-- This is a feed of folder containing:
folder1\
<!-- This is a feed of folder1 containing:
folder2
docid1
-->
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<atom:title>Folder1's Children - page 3</atom:title>
<atom:id>http://www.cmis.org/rep1/folder1/children/3</atom:id>
<atom:link href="http://www.cmis.org/rep1/folder1/children/3" />
<!-- Points to the folder entry document -->
<atom:link rel="cmis-source" href="http://www.cmis.org/rep1/folder1" />
<atom:updated>2007-12-31T12:00:00</atom:updated>
<atom:link rel="cmis-source"
href="http://www.cmis.org/rep1/folder1" />
<!-- RFC 5005 Feed Paging -->
<atom:link rel="first"
@@ -33,25 +33,28 @@
<atom:link rel="last"
href="http://www.cmis.org/rep1/folder1/children/last" />
<!-- sub-folder 1 -->
<atom:entry xml:base="http://tempuri.org" xml:lang="en-US">
<title>Folder Entry example (folder2)</title>
<atom:title>Folder1's Children - page 3</atom:title>
<atom:updated>2007-12-31T12:00:00</atom:updated>
<!-- child folder2 -->
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid2) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/folder-entry2</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/folder-entry2" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/folder-entry2" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/folder-entry2" />
@@ -65,22 +68,13 @@
<atom:link rel="cmis-type"
href="http://www.cmis.org/rep1/type/emailfolder" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid2) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<cmis:properties>
<cmis:objectId>folderid2</cmis:objectId>
<cmis:baseType>folder</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>emailfolder</cmis:objectType>
<cmis:parentId>folderid1</cmis:parentId>
</cmis:properties>
<atom:title>Folder Entry2 example</atom:title>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -94,26 +88,48 @@
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
<cmis:canGetChildren>true</cmis:canGetChildren>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
folderid1
</cmis:propertyID>
<cmis:propertyID cmis:name="parentId">
parentFolderId1
</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">
emailfolder
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
folder
</cmis:propertyString>
</cmis:properties>
</atom:entry>
<atom:entry xml:base="http://tempuri.org" xml:lang="">
<title>Document Entry example</title>
<!-- child doc -->
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit-media"
@@ -139,47 +155,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry" />
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry example</atom:title>
<cmis:properties>
<cmis:objectId>docid1</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<cmis:isCheckedOut>false</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>true</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>true</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<cmis:isVersionSeriesCheckedOut>
false
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy></cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID></cmis:versionSeriesCheckedOutID>
<cmis:checkinComment>
This is the initial checkin comment
</cmis:checkinComment>
<cmis:versionLabel>1.0</cmis:versionLabel>
<cmis:contentStreamLength>70</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -201,6 +187,70 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyBoolean cmis:name="isCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean
cmis:name="isVersionSeriesCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
docid1
</cmis:propertyID>
<cmis:propertyID cmis:name="versionSeriesCheckedOutID"></cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">
70
</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">
email
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
document
</cmis:propertyString>
<cmis:propertyString
cmis:name="versionSeriesCheckedOutBy">
</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">
This is the initial checkin comment
</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">
1.0
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">
text/plain
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">
foo.txt
</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>
<!-- notification of more items -->

View File

@@ -5,10 +5,9 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../ATOM4CMIS.xsd http://www.cmis.org/2008/05 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<!-- This is a feed of folder containing:
folder1\
<!-- This is a feed of folder1 containing:
folder2\
docid2
docid1
@@ -16,15 +15,15 @@
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<atom:title>Folder1's Children - page 3</atom:title>
<atom:id>http://www.cmis.org/rep1/folder1/children/3</atom:id>
<atom:link href="http://www.cmis.org/rep1/folder1/children/3" />
<!-- Points to the folder entry document -->
<atom:link rel="cmis-source"
href="http://www.cmis.org/rep1/folder1" />
<atom:updated>2007-12-31T12:00:00</atom:updated>
<!-- RFC 5005 Feed Paging -->
<atom:link rel="first"
href="http://www.cmis.org/rep1/folder1/children" />
@@ -35,25 +34,28 @@
<atom:link rel="last"
href="http://www.cmis.org/rep1/folder1/children/last" />
<!-- sub-folder 1 -->
<atom:entry xml:base="http://tempuri.org" xml:lang="en-US">
<title>Folder Entry example (folder2)</title>
<atom:title>Folder1's Children - page 3</atom:title>
<atom:updated>2007-12-31T12:00:00</atom:updated>
<!-- child folder2 -->
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid2) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/folder-entry2</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/folder-entry2" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/folder-entry2" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/folder-entry2" />
@@ -67,22 +69,13 @@
<atom:link rel="cmis-type"
href="http://www.cmis.org/rep1/type/emailfolder" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid2) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<cmis:properties>
<cmis:objectId>folderid2</cmis:objectId>
<cmis:baseType>folder</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>emailfolder</cmis:objectType>
<cmis:parentId>folderid1</cmis:parentId>
</cmis:properties>
<atom:title>Folder Entry2 example</atom:title>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -97,25 +90,45 @@
<cmis:canGetChildren>true</cmis:canGetChildren>
</cmis:allowableActions>
<!-- docid2 -->
<atom:entry xml:base="http://tempuri.org" xml:lang="">
<title>Document Entry example</title>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
folderid2
</cmis:propertyID>
<cmis:propertyID cmis:name="parentId">
folderid1
</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">
emailfolder
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
folder
</cmis:propertyString>
</cmis:properties>
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry2">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry2</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry2" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry2" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry2" />
<atom:link rel="edit-media"
@@ -141,51 +154,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry2" />
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry2">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry2 example</atom:title>
<cmis:properties>
<cmis:objectId>docid2</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>
2001-12-31T12:00:00
</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<cmis:isCheckedOut>false</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>true</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>
true
</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<cmis:isVersionSeriesCheckedOut>
false
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy></cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID></cmis:versionSeriesCheckedOutID>
<cmis:checkinComment>
This is the initial checkin comment
</cmis:checkinComment>
<cmis:versionLabel>1.0</cmis:versionLabel>
<cmis:contentStreamLength>700</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo2.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry2
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -211,27 +190,95 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyBoolean cmis:name="isCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean
cmis:name="isLatestMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean
cmis:name="isVersionSeriesCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
docid2
</cmis:propertyID>
<cmis:propertyID
cmis:name="versionSeriesCheckedOutID">
</cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">
70
</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">
email
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
document
</cmis:propertyString>
<cmis:propertyString
cmis:name="versionSeriesCheckedOutBy">
</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">
This is the initial checkin comment
</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">
1.0
</cmis:propertyString>
<cmis:propertyString
cmis:name="contentStreamMimetype">
text/plain
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">
foo.txt
</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>
</atom:entry>
<atom:entry xml:base="http://tempuri.org" xml:lang="">
<title>Document Entry example</title>
<!-- child doc -->
<atom:entry>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/document-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/document-entry" />
<atom:link rel="edit-media"
@@ -257,47 +304,17 @@
<atom:link rel="cmis-stream"
href="http://www.cmis.org/rep1/media/document-entry" />
<!-- atom:content -->
<atom:content
src="http://www.cmis.org/rep1/media/document-entry">
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:summary>
<!-- auto-generated HTML table of properties -->
</atom:summary>
<atom:title>Document Entry example</atom:title>
<cmis:properties>
<cmis:objectId>docid1</cmis:objectId>
<cmis:baseType>document</cmis:baseType>
<cmis:lastModifiedBy>
2001-12-31T12:00:00
</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>email</cmis:objectType>
<cmis:isCheckedOut>false</cmis:isCheckedOut>
<cmis:isLatestVersion>true</cmis:isLatestVersion>
<cmis:isMajorVersion>true</cmis:isMajorVersion>
<cmis:isLatestMajorVersion>true</cmis:isLatestMajorVersion>
<cmis:isImmutable>false</cmis:isImmutable>
<cmis:isVersionSeriesCheckedOut>
false
</cmis:isVersionSeriesCheckedOut>
<cmis:versionSeriesCheckedOutBy></cmis:versionSeriesCheckedOutBy>
<cmis:versionSeriesCheckedOutID></cmis:versionSeriesCheckedOutID>
<cmis:checkinComment>
This is the initial checkin comment
</cmis:checkinComment>
<cmis:versionLabel>1.0</cmis:versionLabel>
<cmis:contentStreamLength>70</cmis:contentStreamLength>
<cmis:contentStreamMimetype>
text/plain
</cmis:contentStreamMimetype>
<cmis:contentStreamName>foo.txt</cmis:contentStreamName>
<cmis:contentStreamURI>
http://www.cmis.org/rep1/media/document-entry
</cmis:contentStreamURI>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -319,8 +336,73 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyBoolean cmis:name="isCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isLatestMajorVersion">
true
</cmis:propertyBoolean>
<cmis:propertyBoolean cmis:name="isImmutable">
false
</cmis:propertyBoolean>
<cmis:propertyBoolean
cmis:name="isVersionSeriesCheckedOut">
false
</cmis:propertyBoolean>
<cmis:propertyDateTime cmis:name="lastModifiedBy">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">
2001-12-31T12:00:00
</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">
docid1
</cmis:propertyID>
<cmis:propertyID cmis:name="versionSeriesCheckedOutID"></cmis:propertyID>
<cmis:propertyInteger cmis:name="contentStreamLength">
70
</cmis:propertyInteger>
<cmis:propertyString cmis:name="objectType">
email
</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">
document
</cmis:propertyString>
<cmis:propertyString
cmis:name="versionSeriesCheckedOutBy">
</cmis:propertyString>
<cmis:propertyString cmis:name="checkinComment">
This is the initial checkin comment
</cmis:propertyString>
<cmis:propertyString cmis:name="versionLabel">
1.0
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamMimetype">
text/plain
</cmis:propertyString>
<cmis:propertyString cmis:name="contentStreamName">
foo.txt
</cmis:propertyString>
<cmis:propertyURI cmis:name="contentStreamURI">
http://www.cmis.org/rep1/media/document-entry
</cmis:propertyURI>
</cmis:properties>
</atom:entry>
<!-- notification of more items -->
<cmis:hasMoreItems>true</cmis:hasMoreItems>
</atom:feed>

View File

@@ -5,25 +5,25 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../ATOM4CMIS.xsd http://www.cmis.org/2008/05 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Folder Entry example</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid1) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/folder-entry</atom:id>
<atom:link rel='self' href="http://www.cmis.org/rep1/folder-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self' href="http://www.cmis.org/rep1/folder-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/folder-entry" />
@@ -37,21 +37,13 @@
<atom:link rel="cmis-type"
href="http://www.cmis.org/rep1/type/emailfolder" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Folder Entry Example (folderid1) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<atom:title>Folder Entry example</atom:title>
<cmis:properties>
<cmis:objectId>folderid1</cmis:objectId>
<cmis:baseType>folder</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>emailfolder</cmis:objectType>
<cmis:parentId>ParentFolderId</cmis:parentId>
</cmis:properties>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -65,4 +57,17 @@
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
<cmis:canGetChildren>true</cmis:canGetChildren>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">folderid1</cmis:propertyID>
<cmis:propertyID cmis:name="parentId">parentFolderId1</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">emailfolder</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">folder</cmis:propertyString>
</cmis:properties>
</atom:entry>

View File

@@ -5,25 +5,24 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../ATOM4CMIS.xsd http://www.cmis.org/2008/05 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Policy Entry example</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Policy Entry Example (policyid1) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/policy-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/policy-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/policy-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/v-entry" />
@@ -37,21 +36,13 @@
<atom:link rel="cmis-target"
href="http://www.cmis.org/rep1/policy-entry/target" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Policy Entry Example (policyid1) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<cmis:properties>
<cmis:objectId>policyid1</cmis:objectId>
<cmis:baseType>policy</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>securitypolicy</cmis:objectType>
<cmis:source>docid1</cmis:source>
<cmis:target>docid2</cmis:target>
</cmis:properties>
<atom:title>Policy Entry example</atom:title>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -61,4 +52,15 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">policyid1</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">security policy</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">policy</cmis:propertyString>
</cmis:properties>
</atom:entry>

View File

@@ -2,7 +2,7 @@
<cmis:query xmlns:cmis="http://www.cmis.org/2008/05"
xmlns:p="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cmis.org/2008/05 ../CMIS-REST.xsd ">
xsi:schemaLocation="http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<cmis:statement>SELECT * FROM document</cmis:statement>
<cmis:searchAllVersions>true</cmis:searchAllVersions>
<cmis:pageSize>0</cmis:pageSize>

View File

@@ -5,26 +5,24 @@
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2005/Atom ../ATOM4CMIS.xsd http://www.cmis.org/2008/05 C:\Java\eclipse\workspace\p8cmis\src\main\resources\rest-schema\CMIS-REST.xsd ">
xsi:schemaLocation="http://www.w3.org/2005/Atom ATOM4CMIS.xsd http://www.cmis.org/2008/05 CMIS-REST.xsd ">
<title>Relationship Entry example</title>
<atom:author xml:base="http://tempuri.org" xml:lang="">
<atom:name>Al Brown</atom:name>
</atom:author>
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Relationship Entry Example (relid1) Property1 Value1
</atom:content>
<!-- URI to document entry resource -->
<atom:id>http://www.cmis.org/rep1/relationship-entry</atom:id>
<atom:link rel='self'
href="http://www.cmis.org/rep1/relationship-entry" />
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<!-- atom links -->
<atom:link rel='self'
href="http://www.cmis.org/rep1/relationship-entry" />
<atom:link rel="edit"
href="http://www.cmis.org/rep1/relationship-entry" />
@@ -38,21 +36,13 @@
<atom:link rel="cmis-target"
href="http://www.cmis.org/rep1/relationship-entry/target" />
<!-- atom:content -->
<atom:content>
<!-- auto-generated HTML table of properties -->
Relationship Entry Example (relid1) Property1 Value1
</atom:content>
<!-- createdDate -->
<atom:published>2001-12-31T12:00:00</atom:published>
<cmis:properties>
<cmis:objectId>relid1</cmis:objectId>
<cmis:baseType>relationship</cmis:baseType>
<cmis:lastModifiedBy>2001-12-31T12:00:00</cmis:lastModifiedBy>
<cmis:creationDate>2001-12-31T12:00:00</cmis:creationDate>
<cmis:objectType>emaillink</cmis:objectType>
<cmis:source>docid1</cmis:source>
<cmis:target>docid2</cmis:target>
</cmis:properties>
<atom:title>Relationship Entry example</atom:title>
<!-- lastModifiedDate -->
<atom:updated>2001-12-31T12:00:00</atom:updated>
<!-- Optional Allowable actions -->
<cmis:allowableActions>
@@ -62,4 +52,16 @@
<cmis:canAddPolicy>true</cmis:canAddPolicy>
<cmis:canRemovePolicy>true</cmis:canRemovePolicy>
</cmis:allowableActions>
<cmis:properties>
<cmis:propertyDateTime cmis:name="lastModifiedBy">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyDateTime cmis:name="creationDate">2001-12-31T12:00:00</cmis:propertyDateTime>
<cmis:propertyID cmis:name="objectId">relid1</cmis:propertyID>
<cmis:propertyID cmis:name="source">docid1</cmis:propertyID>
<cmis:propertyID cmis:name="target">docid2</cmis:propertyID>
<cmis:propertyString cmis:name="objectType">emaillink</cmis:propertyString>
<cmis:propertyString cmis:name="baseType">relationship</cmis:propertyString>
</cmis:properties>
</atom:entry>

View File

@@ -20,9 +20,8 @@
<cmis:capabilityVersionSpecificFiling>true</cmis:capabilityVersionSpecificFiling>
<cmis:capabilityPWCUpdateable>true</cmis:capabilityPWCUpdateable>
<cmis:capabilityAllVersionsSearchable>true</cmis:capabilityAllVersionsSearchable>
<cmis:capabilityInnerJoin>true</cmis:capabilityInnerJoin>
<cmis:capabilityOuterJoin>true</cmis:capabilityOuterJoin>
<cmis:capabilityFullText>fulltextwithmetadata</cmis:capabilityFullText>
<cmis:capabilityJoin>innerAndOuter</cmis:capabilityJoin>
<cmis:capabilityFullText>fulltextandstructured</cmis:capabilityFullText>
</cmis:capabilities>
<cmis:repositorySpecificInformation>Welcome to ACME 99</cmis:repositorySpecificInformation>
</cmis:repositoryInfo>

View File

@@ -20,6 +20,7 @@
<cmis:isContentStreamAllowed>true</cmis:isContentStreamAllowed>
<cmis:isControllable>true</cmis:isControllable>
<!-- optional property definitions -->
<cmis:property cmis:id="foo1">
<cmis:displayName>foo1</cmis:displayName>
<cmis:description>Description of foo1</cmis:description>

View File

@@ -25,14 +25,30 @@
package org.alfresco.repo.web.scripts;
import java.io.IOException;
import java.util.HashMap;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import junit.framework.TestCase;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.web.scripts.TestWebScriptServer;
import org.springframework.mock.web.MockHttpServletResponse;
import org.alfresco.web.scripts.TestWebScriptServer.Request;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Base unit test class for web scripts.
@@ -41,11 +57,47 @@ import org.springframework.mock.web.MockHttpServletResponse;
*/
public abstract class BaseWebScriptTest extends TestCase
{
/** Standard HTTP method names */
protected static final String METHOD_POST = "post";
protected static final String METHOD_GET = "get";
protected static final String METHOD_PUT = "put";
protected static final String METHOD_DELETE = "delete";
// Logger
private static final Log logger = LogFactory.getLog(BaseWebScriptTest.class);
/** Local / Remote Server access */
private String defaultRunAs = null;
private RemoteServer remoteServer = null;
private HttpClient httpClient = null;
/**
* Set Remote Server context
*
* @param server remote server
*/
public void setRemoteServer(RemoteServer server)
{
remoteServer = server;
}
/**
* Set Local Run As User
*
* @param localRunAs
*/
public void setDefaultRunAs(String localRunAs)
{
this.defaultRunAs = localRunAs;
}
@Override
protected void setUp() throws Exception
{
super.setUp();
if (remoteServer != null)
{
httpClient = new HttpClient();
httpClient.getParams().setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(remoteServer.username, remoteServer.password));
}
}
/** Test web script server */
private static TestWebScriptServer server = null;
@@ -59,160 +111,222 @@ public abstract class BaseWebScriptTest extends TestCase
return BaseWebScriptTest.server;
}
/**
* "GET" the url and check for the expected status code
* Send Request to Test Web Script Server (as admin)
*
* @param url
* @param req
* @param expectedStatus
* @return
* @return response
* @throws IOException
*/
protected MockHttpServletResponse getRequest(String url, int expectedStatus)
protected Response sendRequest(Request req, int expectedStatus)
throws IOException
{
return getRequest(url, expectedStatus, null);
return sendRequest(req, expectedStatus, null);
}
/**
* "DELETE" the url and check for the expected status code
* Send Request
*
* @param url
* @param expectedStatus
* @return
* @throws IOException
*/
protected MockHttpServletResponse deleteRequest(String url, int expectedStatus)
throws IOException
{
return sendRequest(METHOD_DELETE, url, expectedStatus, null, null);
}
/**
* "GET" the url and check for the expected status code
*
* @param url
* @param req
* @param expectedStatus
* @param asUser
* @return
* @return response
* @throws IOException
*/
protected MockHttpServletResponse getRequest(String url, int expectedStatus, String asUser)
protected Response sendRequest(Request req, int expectedStatus, String asUser)
throws IOException
{
return sendRequest(METHOD_GET, url, expectedStatus, null, null, asUser);
if (logger.isDebugEnabled())
{
logger.debug("Request");
logger.debug(req.getBody() == null ? null : new String(req.getBody()));
}
Response res = null;
if (remoteServer == null)
{
res = sendLocalRequest(req, expectedStatus, asUser);
}
else
{
res = sendRemoteRequest(req, expectedStatus);
}
if (logger.isDebugEnabled())
{
logger.debug("Response:");
logger.debug(res.getContentAsString());
}
if (expectedStatus > 0 && expectedStatus != res.getStatus())
{
// if (res.getStatus() == 500)
// {
// System.out.println(res.getContentAsString());
// }
fail("Status code " + res.getStatus() + " returned, but expected " + expectedStatus + " for " + req.getFullUri() + " (" + req.getMethod() + ")");
}
return res;
}
/**
* "POST" the url and check for the expected status code
* Send Local Request to Test Web Script Server
*
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, String body, String contentType)
throws IOException
{
return postRequest(url, expectedStatus, body.getBytes(), contentType, null);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param req
* @param expectedStatus
* @param asUser
* @return
* @return response
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, String body, String contentType, String asUser)
protected Response sendLocalRequest(final Request req, final int expectedStatus, String asUser)
throws IOException
{
return postRequest(url, expectedStatus, body.getBytes(), contentType, asUser);
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, byte[] body, String contentType)
throws IOException
asUser = (asUser == null) ? defaultRunAs : asUser;
if (asUser == null)
{
return postRequest(url, expectedStatus, body, contentType, null);
return BaseWebScriptTest.getServer().submitRequest(req.getMethod(), req.getFullUri(), req.getHeaders(), req.getBody(), req.getType());
}
/**
* "POST" the url and check for the expected status code
*
* @param url
* @param expectedStatus
* @param asUser
* @return
* @throws IOException
*/
protected MockHttpServletResponse postRequest(String url, int expectedStatus, byte[] body, String contentType, String asUser)
throws IOException
{
return sendRequest(METHOD_POST, url, expectedStatus, body, contentType, asUser);
}
/**
* Send request to Test Web Script Server
*
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @return
* @throws IOException
*/
protected MockHttpServletResponse putRequest(String url, int expectedStatus, String body, String contentType)
throws IOException
{
return sendRequest(METHOD_PUT, url, expectedStatus, body, contentType);
}
/**
*
* @param method
* @param url
* @param expectedStatus
* @param body
* @param contentType
* @param asUser
* @return
* @throws IOException
*/
private MockHttpServletResponse sendRequest(final String method, final String url, final int expectedStatus, final byte[] body, final String contentType, String asUser)
throws IOException
else
{
// send request in context of specified user
String runAsUser = (asUser == null) ? AuthenticationUtil.getSystemUserName() : asUser;
MockHttpServletResponse response = AuthenticationUtil.runAs(new RunAsWork<MockHttpServletResponse>()
return AuthenticationUtil.runAs(new RunAsWork<Response>()
{
@SuppressWarnings("synthetic-access")
public MockHttpServletResponse doWork() throws Exception
public Response doWork() throws Exception
{
return BaseWebScriptTest.getServer().submitRequest(method, url, new HashMap<String, String>(), body, contentType);
return BaseWebScriptTest.getServer().submitRequest(req.getMethod(), req.getFullUri(), req.getHeaders(), req.getBody(), req.getType());
}
}, asUser);
}
}
}, runAsUser);
if (expectedStatus > 0 && expectedStatus != response.getStatus())
/**
* Send Remote Request to stand-alone Web Script Server
*
* @param req
* @param expectedStatus
* @param asUser
* @return response
* @throws IOException
*/
protected Response sendRemoteRequest(Request req, int expectedStatus)
throws IOException
{
//if (response.getStatus() == 500)
//{
// System.out.println(response.getContentAsString());
//}
fail("Status code " + response.getStatus() + " returned, but expected " + expectedStatus + " for " + url + " (" + method + ")");
String uri = req.getFullUri();
if (!uri.startsWith("http"))
{
uri = remoteServer.baseAddress + uri;
}
return response;
// construct method
HttpMethod httpMethod = null;
String method = req.getMethod();
if (method.equalsIgnoreCase("GET"))
{
GetMethod get = new GetMethod(req.getFullUri());
httpMethod = get;
}
else if (method.equalsIgnoreCase("POST"))
{
PostMethod post = new PostMethod(req.getFullUri());
post.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = post;
}
else if (method.equalsIgnoreCase("PUT"))
{
PutMethod put = new PutMethod(req.getFullUri());
put.setRequestEntity(new ByteArrayRequestEntity(req.getBody(), req.getType()));
httpMethod = put;
}
else if (method.equalsIgnoreCase("DELETE"))
{
DeleteMethod del = new DeleteMethod(req.getFullUri());
httpMethod = del;
}
else
{
throw new AlfrescoRuntimeException("Http Method " + method + " not supported");
}
if (req.getHeaders() != null)
{
for (Map.Entry<String, String> header : req.getHeaders().entrySet())
{
httpMethod.setRequestHeader(header.getKey(), header.getValue());
}
}
// execute method
httpClient.executeMethod(httpMethod);
return new HttpMethodResponse(httpMethod);
}
/**
* Remote Context
*/
public static class RemoteServer
{
public String baseAddress;
public String username;
public String password;
}
/**
* HttpMethod wrapped as Web Script Test Response
*/
public static class HttpMethodResponse
implements Response
{
private HttpMethod method;
public HttpMethodResponse(HttpMethod method)
{
this.method = method;
}
public byte[] getContentAsByteArray()
{
try
{
return method.getResponseBody();
}
catch (IOException e)
{
return null;
}
}
public String getContentAsString() throws UnsupportedEncodingException
{
try
{
return method.getResponseBodyAsString();
}
catch (IOException e)
{
return null;
}
}
public String getContentType()
{
return getHeader("Content-Type");
}
public String getHeader(String name)
{
Header header = method.getResponseHeader(name);
return (header != null) ? header.getValue() : null;
}
public int getStatus()
{
return method.getStatusCode();
}
}
}

View File

@@ -30,11 +30,14 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test the Activity Service's User Feed Control Web Script API
@@ -116,7 +119,7 @@ public class FeedControlTest extends BaseWebScriptTest
feedControl.put("appToolId", appToolId);
int expectedStatus = 200;
MockHttpServletResponse response = postRequest(URL_CONTROL, expectedStatus, feedControl.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_CONTROL, feedControl.toString(), "application/json"), expectedStatus);
if (logger.isDebugEnabled())
{
@@ -128,7 +131,7 @@ public class FeedControlTest extends BaseWebScriptTest
{
// Get (retrieve) feed controls
int expectedStatus = 200;
MockHttpServletResponse response = getRequest(URL_CONTROLS, expectedStatus);
Response response = sendRequest(new GetRequest(URL_CONTROLS), expectedStatus);
JSONArray result = new JSONArray(response.getContentAsString());
if (logger.isDebugEnabled())
@@ -151,7 +154,7 @@ public class FeedControlTest extends BaseWebScriptTest
{
// Unset (delete) feed control
int expectedStatus = 200;
MockHttpServletResponse response = deleteRequest(URL_CONTROL + "?s=" + TEST_SITE_ID + "&a=" + TEST_APP_TOOL_ID, expectedStatus);
Response response = sendRequest(new DeleteRequest(URL_CONTROL + "?s=" + TEST_SITE_ID + "&a=" + TEST_APP_TOOL_ID), expectedStatus);
if (logger.isDebugEnabled())
{

View File

@@ -37,11 +37,15 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Blog Web Script API
@@ -178,7 +182,7 @@ public class BlogServiceTest extends BaseWebScriptTest
throws Exception
{
JSONObject post = getRequestObject(title, content, tags, isDraft);
MockHttpServletResponse response = postRequest(URL_BLOG_POSTS, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_BLOG_POSTS, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -203,7 +207,7 @@ public class BlogServiceTest extends BaseWebScriptTest
throws Exception
{
JSONObject post = getRequestObject(title, content, tags, isDraft);
MockHttpServletResponse response = putRequest(URL_BLOG_POST + name, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_BLOG_POST + name, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -217,7 +221,7 @@ public class BlogServiceTest extends BaseWebScriptTest
private JSONObject getPost(String name, int expectedStatus)
throws Exception
{
MockHttpServletResponse response = getRequest(URL_BLOG_POST + name, expectedStatus);
Response response = sendRequest(new GetRequest(URL_BLOG_POST + name), expectedStatus);
if (expectedStatus == 200)
{
JSONObject result = new JSONObject(response.getContentAsString());
@@ -245,7 +249,7 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
MockHttpServletResponse response = postRequest(getCommentsUrl(nodeRef), expectedStatus, comment.toString(), "application/json");
Response response = sendRequest(new PostRequest(getCommentsUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -263,7 +267,7 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
MockHttpServletResponse response = putRequest(getCommentUrl(nodeRef), expectedStatus, comment.toString(), "application/json");
Response response = sendRequest(new PutRequest(getCommentUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -385,7 +389,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void testGetAll() throws Exception
{
String url = URL_BLOG_POSTS;
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size + drafts.size together
@@ -395,7 +399,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void testGetNew() throws Exception
{
String url = URL_BLOG_POSTS + "/new";
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size
@@ -405,7 +409,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void _testGetDrafts() throws Exception
{
String url = URL_BLOG_POSTS + "/mydrafts";
MockHttpServletResponse response = getRequest(URL_BLOG_POSTS, 200);
Response response = sendRequest(new GetRequest(URL_BLOG_POSTS), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have drafts.size resultss
@@ -413,7 +417,7 @@ public class BlogServiceTest extends BaseWebScriptTest
// the second user should have zero
this.authenticationComponent.setCurrentUser(USER_TWO);
response = getRequest(url, 200);
response = sendRequest(new GetRequest(url), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(0, result.getInt("total"));
this.authenticationComponent.setCurrentUser(USER_ONE);
@@ -423,7 +427,7 @@ public class BlogServiceTest extends BaseWebScriptTest
public void _testMyPublished() throws Exception
{
String url = URL_BLOG_POSTS + "/mypublished";
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size results
@@ -431,7 +435,7 @@ public class BlogServiceTest extends BaseWebScriptTest
// the second user should have zero
this.authenticationComponent.setCurrentUser(USER_TWO);
response = getRequest(url, 200);
response = sendRequest(new GetRequest(url), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(0, result.getInt("total"));
this.authenticationComponent.setCurrentUser(USER_ONE);
@@ -447,21 +451,21 @@ public class BlogServiceTest extends BaseWebScriptTest
JSONObject commentTwo = createComment(nodeRef, "comment", "content", 200);
// fetch the comments
MockHttpServletResponse response = getRequest(getCommentsUrl(nodeRef), 200);
Response response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertEquals(2, result.getInt("total"));
// add another one
JSONObject commentThree = createComment(nodeRef, "comment", "content", 200);
response = getRequest(getCommentsUrl(nodeRef), 200);
response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(3, result.getInt("total"));
// delete the last comment
response = deleteRequest(getCommentUrl(commentThree.getString("nodeRef")), 200);
response = sendRequest(new DeleteRequest(getCommentUrl(commentThree.getString("nodeRef"))), 200);
response = getRequest(getCommentsUrl(nodeRef), 200);
response = sendRequest(new GetRequest(getCommentsUrl(nodeRef)), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(2, result.getInt("total"));

View File

@@ -36,10 +36,14 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Discussions Web Script API
@@ -151,7 +155,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject post = new JSONObject();
post.put("title", title);
post.put("content", content);
MockHttpServletResponse response = postRequest(URL_FORUM_POSTS, expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_FORUM_POSTS, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -171,7 +175,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject post = new JSONObject();
post.put("title", title);
post.put("content", content);
MockHttpServletResponse response = putRequest(getPostUrl(nodeRef), expectedStatus, post.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_FORUM_POST + name, post.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -185,7 +189,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
private JSONObject getPost(String name, int expectedStatus)
throws Exception
{
MockHttpServletResponse response = getRequest(URL_FORUM_POST + name, expectedStatus);
Response response = sendRequest(new GetRequest(URL_FORUM_POST + name), expectedStatus);
if (expectedStatus == 200)
{
JSONObject result = new JSONObject(response.getContentAsString());
@@ -213,7 +217,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
JSONObject reply = new JSONObject();
reply.put("title", title);
reply.put("content", content);
MockHttpServletResponse response = postRequest(getRepliesUrl(nodeRef), expectedStatus, reply.toString(), "application/json");
Response response = sendRequest(new PostRequest(getRepliesUrl(nodeRef), reply.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
@@ -224,6 +228,23 @@ public class DiscussionServiceTest extends BaseWebScriptTest
return result.getJSONObject("item");
}
private JSONObject updateComment(String nodeRef, String title, String content, int expectedStatus)
throws Exception
{
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
Response response = sendRequest(new PutRequest(getPostUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200)
{
return null;
}
//logger.debug("Comment updated: " + response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
return result.getJSONObject("item");
}
// Tests
@@ -268,7 +289,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
public void testGetAll() throws Exception
{
String url = URL_FORUM_POSTS;
MockHttpServletResponse response = getRequest(url, 200);
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// we should have posts.size + drafts.size together
@@ -282,10 +303,10 @@ public class DiscussionServiceTest extends BaseWebScriptTest
String name = item.getString("name");
// delete the post
MockHttpServletResponse response = deleteRequest(URL_FORUM_POST + name, 200);
Response response = sendRequest(new DeleteRequest(URL_FORUM_POST + name), 200);
// try to fetch it again
getRequest(URL_FORUM_POST + name, 404);
sendRequest(new GetRequest(URL_FORUM_POST + name), 404);
}
public void testAddReply() throws Exception
@@ -307,7 +328,7 @@ public class DiscussionServiceTest extends BaseWebScriptTest
assertEquals("test2", reply2.getString("content"));
// fetch all replies for the post
MockHttpServletResponse response = getRequest(getRepliesUrl(postNodeRef), 200);
Response response = sendRequest(new GetRequest(getRepliesUrl(postNodeRef)), 200);
logger.debug(response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
// check the number of replies

View File

@@ -50,9 +50,13 @@ import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.util.PropertyMap;
import org.alfresco.util.URLEncoder;
import org.alfresco.web.scripts.Status;
<<<<<<< .working
import org.apache.commons.lang.RandomStringUtils;
=======
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
>>>>>>> .merge-right.r9819
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit Test to test Invite Web Script API
@@ -279,11 +283,18 @@ public class InviteServiceTest extends BaseWebScriptTest
private void deletePersonByUserName(String userName)
{
<<<<<<< .working
// delete authentication if authentication exists for given user name
if (this.authenticationService.authenticationExists(userName))
{
this.authenticationService.deleteAuthentication(userName);
}
=======
// Inviter sends invitation to Invitee to join a Site
String startInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_START + "?inviteeEmail=" + inviteeEmail
+ "&siteShortName=" + siteShortName;
Response response = sendRequest(new GetRequest(startInviteUrl), expectedStatus);
>>>>>>> .merge-right.r9819
// delete user account
if (this.mutableAuthenticationDao.userExists(userName))
@@ -480,10 +491,15 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteId = result.getString("inviteId");
// Inviter cancels pending invitation
<<<<<<< .working
String cancelInviteUrl = URL_INVITE_SERVICE + "/"
+ INVITE_ACTION_CANCEL + "?inviteId=" + inviteId;
MockHttpServletResponse response = getRequest(cancelInviteUrl,
Status.STATUS_OK);
=======
String cancelInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_CANCEL + "?workflowId=" + workflowId;
Response response = sendRequest(new GetRequest(cancelInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testAcceptInvite() throws Exception
@@ -501,6 +517,7 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteeUserName = result.getString("inviteeUserName");
// Invitee accepts invitation to a Site from Inviter
<<<<<<< .working
String acceptInviteUrl = URL_INVITE_SERVICE + "/" + inviteId + "/" + inviteTicket + "/accept";
MockHttpServletResponse response = putRequest(acceptInviteUrl,
Status.STATUS_OK, null, null);
@@ -518,6 +535,11 @@ public class InviteServiceTest extends BaseWebScriptTest
// there should no longer be any invites identified by invite ID pending
assertEquals(getInvitesResult.getJSONArray("invites").length(), 0);
=======
String acceptInviteUrl = URL_INVITERSP_SERVICE + "/" + INVITE_RSP_ACCEPT + "?workflowId=" + workflowId
+ "&inviteeUserName=" + inviteeUserName + "&siteShortName=" + SITE_SHORT_NAME_INVITE;
Response response = sendRequest(new GetRequest(acceptInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testRejectInvite() throws Exception
@@ -570,11 +592,21 @@ public class InviteServiceTest extends BaseWebScriptTest
JSONObject getInvitesResult = getInvitesByInviteId(inviteId,
Status.STATUS_OK);
<<<<<<< .working
assertEquals(getInvitesResult.getJSONArray("invites").length(), 1);
JSONObject inviteJSONObj = getInvitesResult.getJSONArray("invites").getJSONObject(0);
assertEquals(inviteId, inviteJSONObj.get("inviteId"));
=======
// get hold of invitee user name that was generated as part of starting the invite
String inviteeUserName = result.getString("inviteeUserName");
// Invitee rejects invitation to a Site from Inviter
String rejectInviteUrl = URL_INVITERSP_SERVICE + "/" + INVITE_RSP_REJECT + "?workflowId=" + workflowId
+ "&inviteeUserName=" + inviteeUserName + "&siteShortName=" + SITE_SHORT_NAME_INVITE;
Response response = sendRequest(new GetRequest(rejectInviteUrl), Status.STATUS_OK);
>>>>>>> .merge-right.r9819
}
public void testGetInvitesByInviterUserName() throws Exception

View File

@@ -33,10 +33,11 @@ import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.Status;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.apache.commons.lang.RandomStringUtils;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test person Web Script API
@@ -168,7 +169,8 @@ public class PersonServiceTest extends BaseWebScriptTest
person.put("jobtitle", jobTitle);
person.put("email", email);
MockHttpServletResponse response = postRequest(URL_PEOPLE, expectedStatus, person.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_PEOPLE, person.toString(), "application/json"), expectedStatus);
this.createdPeople.add(userName);
if ((userName != null) && (userName.length() != 0))
{
@@ -202,22 +204,20 @@ public class PersonServiceTest extends BaseWebScriptTest
{
// Test basic GET people with no filters ==
MockHttpServletResponse response = getRequest(URL_PEOPLE, Status.STATUS_OK);
Response response = sendRequest(new GetRequest(URL_PEOPLE), 200);
System.out.println(response.getContentAsString());
}
public void testGetPerson() throws Exception
{
// Get a person that doesn't exist
MockHttpServletResponse response = getRequest(URL_PEOPLE + "/" + "nonExistantUser", 404);
Response response = sendRequest(new GetRequest(URL_PEOPLE + "/" + "nonExistantUser"), 404);
// Create a person and get him/her
String userName = RandomStringUtils.randomNumeric(6);
JSONObject result = createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
"myJobTitle", "myEmailAddress", "myBio", "images/avatar.jpg", Status.STATUS_OK);
response = getRequest(URL_PEOPLE + "/" + userName, Status.STATUS_OK);
"myJobTitle", "myEmailAddress", "myBio", "images/avatar.jpg", 200);
response = sendRequest(new GetRequest(URL_PEOPLE + "/" + userName), 200);
}
public void testUpdatePerson() throws Exception

View File

@@ -24,21 +24,17 @@
*/
package org.alfresco.repo.web.scripts.preference;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.site.SiteModel;
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
import org.json.JSONArray;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test preference Web Script API
@@ -102,7 +98,7 @@ public class PreferenceServiceTest extends BaseWebScriptTest
{
// Get the preferences before they have been set
MockHttpServletResponse resp = getRequest(URL, 200);
Response resp = sendRequest(new GetRequest(URL), 200);
JSONObject jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
@@ -113,12 +109,12 @@ public class PreferenceServiceTest extends BaseWebScriptTest
JSONObject jsonObject = getPreferenceObj();
jsonObject.put("comp1", getPreferenceObj());
resp = postRequest(URL, 200, jsonObject.toString(), "application/json");
assertEquals(0, resp.getContentLength());
resp = sendRequest(new PostRequest(URL, jsonObject.toString(), "application/json"), 200);
assertEquals(0, resp.getContentAsByteArray().length);
// Get the preferences
resp = getRequest(URL, 200);
resp = sendRequest(new GetRequest(URL), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -131,12 +127,12 @@ public class PreferenceServiceTest extends BaseWebScriptTest
jsonObject.put("stringValue", "updated");
jsonObject.put("comp2", getPreferenceObj());
resp = postRequest(URL, 200, jsonObject.toString(), "application/json");
assertEquals(0, resp.getContentLength());
resp = sendRequest(new PostRequest(URL, jsonObject.toString(), "application/json"), 200);
assertEquals(0, resp.getContentAsByteArray().length);
// Get the preferences
resp = getRequest(URL, 200);
resp = sendRequest(new GetRequest(URL), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -149,7 +145,7 @@ public class PreferenceServiceTest extends BaseWebScriptTest
// Filter the preferences retrieved
resp = getRequest(URL + "?pf=comp2", 200);
resp = sendRequest(new GetRequest(URL + "?pf=comp2"), 200);
jsonResult = new JSONObject(resp.getContentAsString());
assertNotNull(jsonResult);
assertTrue(jsonResult.keys().hasNext());
@@ -163,10 +159,10 @@ public class PreferenceServiceTest extends BaseWebScriptTest
// Clear all the preferences
// Test trying to update another user's permissions
postRequest("/api/people/" + USER_BAD + "/preferences", 500, jsonObject.toString(), "application/json");
sendRequest(new PostRequest("/api/people/" + USER_BAD + "/preferences", jsonObject.toString(), "application/json"), 500);
// Test error conditions
getRequest("/api/people/noExistUser/preferences", 404);
sendRequest(new GetRequest("/api/people/noExistUser/preferences"), 404);
}
private JSONObject getPreferenceObj()

View File

@@ -35,9 +35,13 @@ import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.util.GUID;
import org.alfresco.util.PropertyMap;
import org.alfresco.web.scripts.TestWebScriptServer.DeleteRequest;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PutRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test site Web Script API
@@ -103,7 +107,7 @@ public class SiteServiceTest extends BaseWebScriptTest
// Tidy-up any site's create during the execution of the test
for (String shortName : this.createdSites)
{
deleteRequest(URL_SITES + "/" + shortName, 0);
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName), 0);
}
// Clear the list
@@ -137,14 +141,14 @@ public class SiteServiceTest extends BaseWebScriptTest
site.put("title", title);
site.put("description", description);
site.put("isPublic", isPublic);
MockHttpServletResponse response = postRequest(URL_SITES, expectedStatus, site.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES, site.toString(), "application/json"), expectedStatus);
this.createdSites.add(shortName);
return new JSONObject(response.getContentAsString());
}
public void testGetSites() throws Exception
{
MockHttpServletResponse response = getRequest(URL_SITES, 200);
Response response = sendRequest(new GetRequest(URL_SITES), 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(0, result.length());
@@ -174,12 +178,12 @@ public class SiteServiceTest extends BaseWebScriptTest
public void testGetSite() throws Exception
{
// Get a site that doesn't exist
MockHttpServletResponse response = getRequest(URL_SITES + "/" + "somerandomshortname", 404);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + "somerandomshortname"), 404);
// Create a site and get it
String shortName = GUID.generate();
JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
}
@@ -193,14 +197,14 @@ public class SiteServiceTest extends BaseWebScriptTest
result.put("title", "abs123abc");
result.put("description", "123abc123");
result.put("isPublic", false);
MockHttpServletResponse response = putRequest(URL_SITES + "/" + shortName, 200, result.toString(), "application/json");
Response response = sendRequest(new PutRequest(URL_SITES + "/" + shortName, result.toString(), "application/json"), 200);
result = new JSONObject(response.getContentAsString());
assertEquals("abs123abc", result.get("title"));
assertEquals("123abc123", result.get("description"));
assertFalse(result.getBoolean("isPublic"));
// Try and get the site and double check it's changed
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
result = new JSONObject(response.getContentAsString());
assertEquals("abs123abc", result.get("title"));
assertEquals("123abc123", result.get("description"));
@@ -210,20 +214,20 @@ public class SiteServiceTest extends BaseWebScriptTest
public void testDeleteSite() throws Exception
{
// Delete non-existant site
MockHttpServletResponse response = deleteRequest(URL_SITES + "/" + "somerandomshortname", 404);
Response response = sendRequest(new DeleteRequest(URL_SITES + "/" + "somerandomshortname"), 404);
// Create a site
String shortName = GUID.generate();
JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Get the site
response = getRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 200);
// Delete the site
response = deleteRequest(URL_SITES + "/" + shortName, 200);
response = sendRequest(new DeleteRequest(URL_SITES + "/" + shortName), 200);
// Get the site
response = getRequest(URL_SITES + "/" + shortName, 404);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName), 404);
}
public void testGetMemeberships() throws Exception
@@ -233,7 +237,7 @@ public class SiteServiceTest extends BaseWebScriptTest
createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Check the memberships
MockHttpServletResponse response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS), 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(1, result.length());
@@ -256,7 +260,7 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the memebership
MockHttpServletResponse response = postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -264,7 +268,7 @@ public class SiteServiceTest extends BaseWebScriptTest
assertEquals(USER_TWO, membership.getJSONObject("person").get("userName"));
// Get the membership list
response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS), 200);
JSONArray result2 = new JSONArray(response.getContentAsString());
assertNotNull(result2);
assertEquals(2, result2.length());
@@ -277,11 +281,11 @@ public class SiteServiceTest extends BaseWebScriptTest
createSite("myPreset", shortName, "myTitle", "myDescription", true, 200);
// Test error conditions
getRequest(URL_SITES + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE, 404);
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/baduser", 404);
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 404);
sendRequest(new GetRequest(URL_SITES + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE), 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/baduser"), 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404);
MockHttpServletResponse response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_ONE, 200);
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_ONE), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -306,12 +310,12 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the memebership
MockHttpServletResponse response = postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
Response response = sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
JSONObject newMember = new JSONObject(response.getContentAsString());
// Update the role
newMember.put("role", SiteModel.SITE_COLLABORATOR);
response = putRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200, newMember.toString(), "application/json");
response = sendRequest(new PutRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, newMember.toString(), "application/json"), 200);
JSONObject result = new JSONObject(response.getContentAsString());
// Check the result
@@ -319,7 +323,7 @@ public class SiteServiceTest extends BaseWebScriptTest
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
// Double check and get the membership for user two
response = getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200);
response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200);
result = new JSONObject(response.getContentAsString());
assertEquals(SiteModel.SITE_COLLABORATOR, result.get("role"));
assertEquals(USER_TWO, result.getJSONObject("person").get("userName"));
@@ -339,13 +343,13 @@ public class SiteServiceTest extends BaseWebScriptTest
membership.put("person", person);
// Post the membership
postRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, 200, membership.toString(), "application/json");
sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
// Delete the membership
deleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 200);
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200);
// Check that the membership has been deleted
getRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO, 404);
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404);
}

View File

@@ -37,9 +37,11 @@ import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.util.GUID;
import org.alfresco.web.scripts.TestWebScriptServer.GetRequest;
import org.alfresco.web.scripts.TestWebScriptServer.PostRequest;
import org.alfresco.web.scripts.TestWebScriptServer.Response;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletResponse;
/**
* Unit test to test thumbnail web script API
@@ -110,13 +112,13 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "webpreview");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
System.out.println(response.getContentAsString());
}
// Check getAll whilst we are here
MockHttpServletResponse getAllResp = this.getRequest(getThumbnailsURL(jpgNode), 200);
Response getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
JSONArray getArr = new JSONArray(getAllResp.getContentAsString());
assertNotNull(getArr);
assertEquals(0, getArr.length());
@@ -125,16 +127,16 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "medium");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
System.out.println(response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
String thumbnailUrl = result.getString("url").substring(17);
System.out.println(thumbnailUrl);
response = getRequest(thumbnailUrl, 200);
response = sendRequest(new GetRequest(thumbnailUrl), 200);
// Check getAll whilst we are here
getAllResp = this.getRequest(getThumbnailsURL(jpgNode), 200);
getAllResp = sendRequest(new GetRequest(getThumbnailsURL(jpgNode)), 200);
getArr = new JSONArray(getAllResp.getContentAsString());
assertNotNull(getArr);
assertEquals(1, getArr.length());
@@ -203,7 +205,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "webpreview");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
assertEquals("", response.getContentAsString().trim());
getWait(pdfNode, "webpreview");
}
@@ -212,7 +214,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
String url = "/api/node/" + jpgNode.getStoreRef().getProtocol() + "/" + jpgNode.getStoreRef().getIdentifier() + "/" + jpgNode.getId() + "/content/thumbnails?as=true";
JSONObject tn = new JSONObject();
tn.put("thumbnailName", "medium");
MockHttpServletResponse response = this.postRequest(url, 200, tn.toString(), "application/json");
Response response = sendRequest(new PostRequest(url, tn.toString(), "application/json"), 200);
assertEquals("", response.getContentAsString().trim());
getWait(jpgNode, "medium");
@@ -232,7 +234,7 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
fail("Thumbnail never gets created " + thumbnailName);
}
MockHttpServletResponse response = getRequest(url, 0);
Response response = sendRequest(new GetRequest(url), 0);
if (response.getStatus() == 200)
{
break;
@@ -257,13 +259,13 @@ public class ThumbnailServiceTest extends BaseWebScriptTest
if (this.contentService.getTransformer(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_FLASH) != null)
{
// Check that there is no place holder set for webpreview
this.getRequest(getThumbnailsURL(pdfNode) + "/webpreview", 404);
this.getRequest(getThumbnailsURL(pdfNode) + "/webpreview?ph=true", 404);
sendRequest(new GetRequest(getThumbnailsURL(pdfNode) + "/webpreview"), 404);
sendRequest(new GetRequest(getThumbnailsURL(pdfNode) + "/webpreview?ph=true"), 404);
}
// Check that here is a place holder for medium
this.getRequest(getThumbnailsURL(jpgNode) + "/medium", 404);
this.getRequest(getThumbnailsURL(jpgNode) + "/medium?ph=true", 200);
sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/medium"), 404);
sendRequest(new GetRequest(getThumbnailsURL(jpgNode) + "/medium?ph=true"), 200);
System.out.println(getThumbnailsURL(jpgNode) + "/medium?ph=true");
}

View File

@@ -4,6 +4,6 @@
<beans>
<import resource="classpath:alfresco/application-context.xml" />
<import resource="classpath:web-services-application-context.xml" />
<import resource="classpath:alfresco/web-services-application-context.xml" />
</beans>

View File

@@ -47,4 +47,8 @@ public interface CMISConstants
public static final QName OBJECTID = new QName(CMIS_200805_NS, "objectId");
public static final QName BASETYPE = new QName(CMIS_200805_NS, "baseType");
public static final String REL_CHILDREN = "cmis-children";
public static final String REL_PARENT = "cmis-parent";
public static final String REL_PARENTS = "cmis-parents";
public static final String REL_ALLVERSIONS = "cmis-allversions";
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/2008/05">
<title>Updated Title ${NAME}</title>
<content>updated content ${NAME}</content>
</entry>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/2008/05">
</entry>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/2008/05">
<title>Test Document ${GUID}</title>
<summary>Test Document ${GUID} Summary</summary>
<content type="html">test content ${GUID}</content>
<title>${NAME}</title>
<summary>${NAME} (summary)</summary>
<content type="html">test content ${NAME}</content>
<cmis:properties>
<cmis:baseType>document</cmis:baseType>
</cmis:properties>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/2008/05">
<title>CMIS Test Folder ${GUID}</title>
<summary>CMIS Test Folder ${GUID} Summary</summary>
<title>${NAME}</title>
<summary>${NAME} (summary)</summary>
<cmis:properties>
<cmis:baseType>folder</cmis:baseType>
</cmis:properties>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/2008/05">
<title>Updated Title ${NAME}</title>
<content>updated content ${NAME}</content>
</entry>

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/CMIS/1.0">
<title>Iñtërnâtiônàlizætiøn - 2</title>
<id>urn:uuid:12345678-1234-1234-1234-123412341234</id>
<summary>Create test 1 summary</summary>
<updated>2007-02-123T17:09:02Z</updated>
<author><name>Doolittle</name></author>
<content type="html">content 1</content>
<cmis:object>
<cmis:uri>http://example.org/atom04</cmis:uri>
<cmis:baseType>document</cmis:baseType>
<cmis:keyword index="0">XML</cmis:keyword>
<cmis:keyword index="1">standards</cmis:keyword>
</cmis:object>
</entry>
post /api/path/workspace/SpacesStore//children application/atom+xml <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/CMIS/1.0"><title>Iñtërnâtiônàlizætiøn - 20</title><id>urn:uuid:12345678-1234-1234-1234-123412341234</id><summary>Create folder 1 summary</summary><updated>2007-02-123T17:09:02Z</updated><author><name>Doolittle</name></author><content type="html">content 1</content><cmis:object><cmis:baseType>folder</cmis:baseType></cmis:object></entry>
post /test/ext application/atom+xml <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/CMIS/1.0"><title>Iñtërnâtiônàlizætiøn - 6</title><id>urn:uuid:12345678-1234-1234-1234-123412341234</id><summary>Create test 1 summary</summary><updated>2007-02-123T17:09:02Z</updated><author><name>Doolittle</name></author><content type="html">content 1</content><cmis:object><cmis:baseType>document</cmis:baseType></cmis:object></entry>

Binary file not shown.

BIN
source/test/WcfCmisTest.zip Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,225 @@
/*
* Copyright (C) 2005-2008 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.ws.example;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.alfresco.repo.cmis.ws.DocumentOrFolderObjectType;
import org.alfresco.repo.cmis.ws.GetChildren;
import org.alfresco.repo.cmis.ws.GetChildrenResponse;
import org.alfresco.repo.cmis.ws.GetRootFolder;
import org.alfresco.repo.cmis.ws.NavigationServicePort;
import org.alfresco.repo.cmis.ws.RepositoryServicePort;
import org.alfresco.repo.cmis.ws.TypesOfObjectsEnum;
import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSPasswordCallback;
import org.apache.ws.security.handler.WSHandlerConstants;
/**
* This helper-class contain all necessary for <b>SimpleCmisWsTest</b> correct working service-methods
*
* @author Dmitry Velichkevich
*/
public class ExecutableServicesHelper
{
private static final QName NAVIGATION_SERVICE_NAME = new QName("http://www.cmis.org/ns/1.0", "NavigationService");
private static final QName REPOSITORY_SERVICE_NAME = new QName("http://www.cmis.org/ns/1.0", "RepositoryService");
private static final String NAVIGATION_SERVER_URL_POSTFIX = "/alfresco/cmis/NavigationService?wsdl";
private static final String REPOSITORY_SERVER_URL_POSTFIX = "/alfresco/cmis/RepositoryService?wsdl";
private String username;
private String password;
private Service navigationServicesFactory;
private Service repositoryServicesFactory;
/**
* @param username - an existent authentication user name
* @param password - appropriate password for specified user name
* @param serverAddress - IP address (or domain name) and port for the server to connect
* @throws Exception - an caught <b>MalformedURLException</b> in time of server connect <b>URL</b> creation
*/
public ExecutableServicesHelper(String username, String password, String serverAddress) throws Exception
{
this.username = username;
this.password = password;
try
{
navigationServicesFactory = Service.create(new URL(serverAddress + NAVIGATION_SERVER_URL_POSTFIX), NAVIGATION_SERVICE_NAME);
repositoryServicesFactory = Service.create(new URL(serverAddress + REPOSITORY_SERVER_URL_POSTFIX), REPOSITORY_SERVICE_NAME);
}
catch (MalformedURLException e)
{
throw new Exception("Field to connect to specified URL. Exception Message: " + e.getMessage());
}
}
/**
* This method simplify <b>RepositoryServicePort</b> instance creation
*
* @return an instance of <b>RepositoryServicePort</b>
*/
public RepositoryServicePort receiveAuthorizedRepositoryServicePort()
{
RepositoryServicePort result = repositoryServicesFactory.getPort(RepositoryServicePort.class);
createAuthorizationClient(result);
return result;
}
/**
* This method simplify <b>NavigationServicePort</b> instance creation
*
* @return an instance of <b>NavigationServicePort</b>
*/
public NavigationServicePort receiveAuthorizedNavigationServicePort()
{
NavigationServicePort result = navigationServicesFactory.getPort(NavigationServicePort.class);
createAuthorizationClient(result);
return result;
}
/**
* This method simplify configuring of <b>GetChildren CMIS Service</b> query with "ANY" filter, <b>Company Home Object Identificator</b> and <b>FOLDERS_AND_DOCUMENTS</b>
* entity types.
*
* @param servicesPort - <b>NavigationServicePort</b> configured with <b>WSS4J Client</b> instance
* @return <b>List< DocumentOrFolderObjectType></b> - list of all children elements of <b>Company Home</b> folder
* @throws Exception This exception throws when any <b>CMIS Services</b> operations was failed
*/
public List<DocumentOrFolderObjectType> receiveSpaceContent(NavigationServicePort servicesPort) throws Exception
{
GetChildrenResponse response;
try
{
response = servicesPort.getChildren(configureGetChildrenServiceQuery());
if ((response != null) && (response.getDocumentAndFolderCollection() != null))
{
return response.getDocumentAndFolderCollection().getObject();
}
else
{
return null;
}
}
catch (Exception e)
{
throw new Exception("Can't receive content of Company Home caused: " + e.getMessage());
}
}
/**
* This method simplify receiving of Object Identificator for Company Home Root Folder
*
* @param servicesPort - <b>RepositoryServicePort</b> instance that configured with WSS4J Client
* @return <b>String</b> representation of <b>Object Identificator</b>
* @throws Exception This exception throws when any <b>CMIS Services</b> operations was failed
*/
public String receiveCompanyHomeObjectId(RepositoryServicePort servicesPort) throws Exception
{
try
{
GetRootFolder requestParameters = new GetRootFolder();
return servicesPort.getRootFolder(requestParameters).getRootFolder().getObjectID();
}
catch (Exception e)
{
throw new Exception("Can't receive Repository info caused: " + e.getMessage());
}
}
/**
* This method simplify creation of authorized Client instance with specified user name and appropriate password
*
* @return - an instance of authorized <b>CMIS Client</b>
*/
protected Client createAuthorizationClient(Object servicePortInstance)
{
Map<String, Object> outInterceptorProperties = configureWss4jProperties();
WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(outInterceptorProperties);
return createAndConfigureClientInstance(servicePortInstance, outInterceptor);
}
private GetChildren configureGetChildrenServiceQuery() throws Exception
{
GetChildren requestParameters = new GetChildren();
requestParameters.setFilter("*");
requestParameters.setFolderId(receiveCompanyHomeObjectId(receiveAuthorizedRepositoryServicePort()));
requestParameters.setType(TypesOfObjectsEnum.FOLDERS_AND_DOCUMETS);
return requestParameters;
}
private Client createAndConfigureClientInstance(Object servicePortInstance, WSS4JOutInterceptor outInterceptor)
{
Client client = ClientProxy.getClient(servicePortInstance);
client.getEndpoint().getOutInterceptors().add(new SAAJOutInterceptor());
client.getEndpoint().getOutInterceptors().add(outInterceptor);
return client;
}
private Map<String, Object> configureWss4jProperties()
{
Map<String, Object> outInterceptorProperties = new HashMap<String, Object>();
outInterceptorProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.TIMESTAMP);
outInterceptorProperties.put(WSHandlerConstants.USER, username);
outInterceptorProperties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
outInterceptorProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler()
{
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
((WSPasswordCallback) callbacks[0]).setPassword(password);
}
});
return outInterceptorProperties;
}
}

View File

@@ -0,0 +1,113 @@
/*
* Copyright (C) 2005-2008 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.ws.example;
import java.util.List;
import org.alfresco.repo.cmis.ws.DocumentOrFolderObjectType;
/**
* This class executes simple processing for prompting server address and user name and password for authentication this user on specified server. After successful connection this
* class print contents of Company Home.<br />
* <br />
* This class expects next command-line parameters:<nobr />
* <ul>
* <li><b>Server Address</b> - with form: (IP_ADDRESS|DOMAIN_NAME):PORT;</li>
* <li><b>Username</b> - login name of the existent user;</li>
* <li><b>Password</b> - appropriate password for specified user.</li>
* </ul>
* <b>Example: <font color=green>192.168.0.1:8080 admin admin</font></b> - authenticate an user as admin on <font color=gray><b>http://192.168.0.1:8080/alfresco/</b></font>
* server
*
* @author Dmitry Velichkevich
*/
public class SimpleExecutableCmisServicesUtilizer
{
private static final String FOLDER_IDENTIFICATOR_SAMPLE_STRING = "}folder";
/**
* Executable entry point - represents main life cycle
*
* @param args - not used
* @see SimpleCmisWsTest description
*/
public static void main(String[] args)
{
String username = null;
String password = null;
String serverUrl = null;
if (args.length != 3)
{
System.out.println("Usage: cmis-test.bat server_url username password");
System.out.println("Example : cmis-test.bat http://localhost:8080/ admin admin");
return;
}
else
{
serverUrl = args[0];
username = args[1];
password = args[2];
}
ExecutableServicesHelper servicesHelper;
try
{
servicesHelper = new ExecutableServicesHelper(username, password, serverUrl);
}
catch (Exception e)
{
System.out.println("Can't connect to specified server. Message: " + e.getMessage());
return;
}
List<DocumentOrFolderObjectType> response;
try
{
response = servicesHelper.receiveSpaceContent(servicesHelper.receiveAuthorizedNavigationServicePort());
}
catch (Exception e)
{
System.out.println("Can't receive content of Company Home caused: " + e.getMessage());
return;
}
System.out.println("Outing Company Home contents:");
for (DocumentOrFolderObjectType item : response)
{
if (item.getBaseObjectType().contains(FOLDER_IDENTIFICATOR_SAMPLE_STRING))
{
System.out.println("[" + item.getName() + "]");
}
else
{
System.out.println(item.getName());
}
}
}
}

Binary file not shown.

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="RepositoryServiceSoapBinding" messageEncoding="Text">
<security mode="TransportWithMessageCredential">
<transport />
<message clientCredentialType="UserName" />
</security>
</binding>
<binding name="NavigationServiceSoapBinding" messageEncoding="Text">
<security mode="TransportWithMessageCredential">
<transport />
<message clientCredentialType="UserName" />
</security>
</binding>
<binding name="ObjectServiceSoapBinding" messageEncoding="Mtom">
<security mode="TransportWithMessageCredential">
<transport />
<message clientCredentialType="UserName" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:8443/alfresco/cmis/RepositoryService"
binding="basicHttpBinding" bindingConfiguration="RepositoryServiceSoapBinding"
contract="RepositoryServicePort" name="RepositoryServicePort" />
<endpoint address="https://localhost:8443/alfresco/cmis/NavigationService"
binding="basicHttpBinding" bindingConfiguration="NavigationServiceSoapBinding"
contract="NavigationServicePort" name="NavigationServicePort" />
<endpoint address="https://localhost:8443/alfresco/cmis/ObjectService"
binding="basicHttpBinding" bindingConfiguration="ObjectServiceSoapBinding"
contract="ObjectServicePort" name="ObjectServicePort" />
</client>
</system.serviceModel>
</configuration>

Binary file not shown.