mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge from SEAMIST3
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10721 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
<#macro document node>
|
||||||
|
<#-- TODO: link elements (both APP and CMIS) -->
|
||||||
|
<entry>
|
||||||
|
<title>${node.name}</title>
|
||||||
|
<link rel="alternate" href="${absurl(url.serviceContext)}${node.url}"/>
|
||||||
|
<id>urn:uuid:${node.id}</id>
|
||||||
|
<updated>${xmldate(node.properties.modified)}</updated>
|
||||||
|
<published>${xmldate(node.properties.created)}</published>
|
||||||
|
<summary>${node.properties.description!""}</summary>
|
||||||
|
<author><name>${node.properties.creator}</name></author>
|
||||||
|
<alf:noderef>${node.nodeRef}</alf:noderef>
|
||||||
|
<alf:icon>${absurl(url.context)}${node.icon16}</alf:icon>
|
||||||
|
<#-- TODO: full cmis schema -->
|
||||||
|
<cmis:object>
|
||||||
|
<cmis:object_id>${node.id}</cmis:object_id>
|
||||||
|
<cmis:baseType>document</cmis:baseType>
|
||||||
|
</cmis:object>
|
||||||
|
</entry>
|
||||||
|
</#macro>
|
||||||
|
|
||||||
|
<#macro folder node>
|
||||||
|
<#-- TODO: link elements (both APP and CMIS) -->
|
||||||
|
<entry>
|
||||||
|
<title>${node.name}</title>
|
||||||
|
<link rel="alternate" href="${absurl(url.serviceContext)}${node.url}"/>
|
||||||
|
<id>urn:uuid:${node.id}</id>
|
||||||
|
<updated>${xmldate(node.properties.modified)}</updated>
|
||||||
|
<published>${xmldate(node.properties.created)}</published>
|
||||||
|
<summary>${node.properties.description!""}</summary>
|
||||||
|
<author><name>${node.properties.creator!""}</name></author>
|
||||||
|
<alf:noderef>${node.nodeRef}</alf:noderef>
|
||||||
|
<alf:icon>${absurl(url.context)}${node.icon16}</alf:icon>
|
||||||
|
<#-- TODO: full cmis schema -->
|
||||||
|
<cmis:object>
|
||||||
|
<cmis:object_id>${node.id}</cmis:object_id>
|
||||||
|
<cmis:baseType>folder</cmis:baseType>
|
||||||
|
</cmis:object>
|
||||||
|
</entry>
|
||||||
|
</#macro>
|
@@ -4,4 +4,5 @@
|
|||||||
<url>/api/repository</url>
|
<url>/api/repository</url>
|
||||||
<format default="atom"/>
|
<format default="atom"/>
|
||||||
<authentication>none</authentication>
|
<authentication>none</authentication>
|
||||||
|
<cmis version="0.21"/>
|
||||||
</webscript>
|
</webscript>
|
@@ -1,4 +1,5 @@
|
|||||||
<#import "/org/alfresco/paging.lib.atom.ftl" as pagingLib/>
|
<#import "/org/alfresco/paging.lib.atom.ftl" as pagingLib/>
|
||||||
|
<#import "/org/alfresco/cmis/entries.lib.atom.ftl" as entriesLib/>
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/CMIS/1.0" xmlns:alf="http://www.alfresco.org" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/CMIS/1.0" xmlns:alf="http://www.alfresco.org" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
||||||
<generator version="${server.version}">Alfresco (${server.edition})</generator>
|
<generator version="${server.version}">Alfresco (${server.edition})</generator>
|
||||||
@@ -12,16 +13,10 @@
|
|||||||
<link rel="self" href="${absurl(url.full)?xml}" type="${format.type}"/>
|
<link rel="self" href="${absurl(url.full)?xml}" type="${format.type}"/>
|
||||||
<@pagingLib.cursor cursor=cursor/>
|
<@pagingLib.cursor cursor=cursor/>
|
||||||
<#list results as child>
|
<#list results as child>
|
||||||
<entry>
|
<#if child.isDocument>
|
||||||
<title>${child.name}</title>
|
<@entriesLib.document node=child/>
|
||||||
<link rel="alternate" href="${absurl(url.serviceContext)}${child.url}"/>
|
<#else>
|
||||||
<id>urn:uuid:${child.id}</id>
|
<@entriesLib.folder node=child/>
|
||||||
<updated>${xmldate(child.properties.modified)}</updated>
|
</#if>
|
||||||
<published>${xmldate(child.properties.created)}</published>
|
|
||||||
<summary>${child.properties.description!""}</summary>
|
|
||||||
<author><name>${child.properties.creator}</name></author>
|
|
||||||
<alf:noderef>${child.nodeRef}</alf:noderef>
|
|
||||||
<alf:icon>${absurl(url.context)}${child.icon16}</alf:icon>
|
|
||||||
</entry>
|
|
||||||
</#list>
|
</#list>
|
||||||
</feed>
|
</feed>
|
@@ -2,7 +2,7 @@ script:
|
|||||||
{
|
{
|
||||||
// locate node
|
// locate node
|
||||||
var pathSegments = url.match.split("/");
|
var pathSegments = url.match.split("/");
|
||||||
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id, url.templateArgs.id ];
|
var reference = [ url.templateArgs.store_type, url.templateArgs.store_id ].concat(url.templateArgs.id.split("/"));
|
||||||
model.node = cmis.findNode(pathSegments[2], reference);
|
model.node = cmis.findNode(pathSegments[2], reference);
|
||||||
if (model.node === null)
|
if (model.node === null)
|
||||||
{
|
{
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
<#import "/org/alfresco/cmis/entries.lib.atom.ftl" as entriesLib/>
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/CMIS/1.0" xmlns:alf="http://www.alfresco.org" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
||||||
|
<generator version="${server.version}">Alfresco (${server.edition})</generator>
|
||||||
|
<title>${node.name}</title>
|
||||||
|
<updated>${xmldate(node.properties.modified)}</updated>
|
||||||
|
<icon>${absurl(url.context)}/images/logo/AlfrescoLogo16.ico</icon>
|
||||||
|
<author>
|
||||||
|
<name>${node.properties.creator!""}</name>
|
||||||
|
</author>
|
||||||
|
<id>urn:uuid:${node.id}</id>
|
||||||
|
<link rel="self" href="${absurl(url.full)?xml}" type="${format.type}"/>
|
||||||
|
<@parent node=node.parent recurse=returnToRoot/>
|
||||||
|
</feed>
|
||||||
|
|
||||||
|
<#macro parent node recurse=false>
|
||||||
|
<#if node?exists && node.isContainer>
|
||||||
|
<@entriesLib.folder node=node/>
|
||||||
|
<#if recurse>
|
||||||
|
<@parent node=node.parent recurse=true/>
|
||||||
|
</#if>
|
||||||
|
</#if>
|
||||||
|
</#macro>
|
@@ -0,0 +1,8 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Retrieve Parent Folder</shortname>
|
||||||
|
<description>Retrieve parent folder</description>
|
||||||
|
<url>/api/node/{store_type}/{store_id}/{id}/parent?returnToRoot={returnToRoot}</url>
|
||||||
|
<url>/api/path/{store_type}/{store_id}/{id}/parent?returnToRoot={returnToRoot}</url>
|
||||||
|
<authentication>guest</authentication>
|
||||||
|
<format default="atomfeed">argument</format>
|
||||||
|
</webscript>
|
@@ -0,0 +1,20 @@
|
|||||||
|
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: property filters
|
||||||
|
|
||||||
|
// retrieve parent
|
||||||
|
var returnToRoot = cmis.findArg(args.returnToRoot, headers["CMIS-returnToRoot"]);
|
||||||
|
model.returnToRoot = returnToRoot == "true" ? true : false;
|
||||||
|
}
|
@@ -0,0 +1,24 @@
|
|||||||
|
<#import "/org/alfresco/cmis/entries.lib.atom.ftl" as entriesLib/>
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/CMIS/1.0" xmlns:alf="http://www.alfresco.org" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
||||||
|
<generator version="${server.version}">Alfresco (${server.edition})</generator>
|
||||||
|
<title>${node.name}</title>
|
||||||
|
<updated>${xmldate(node.properties.modified)}</updated>
|
||||||
|
<icon>${absurl(url.context)}/images/logo/AlfrescoLogo16.ico</icon>
|
||||||
|
<author>
|
||||||
|
<name>${node.properties.creator!""}</name>
|
||||||
|
</author>
|
||||||
|
<id>urn:uuid:${node.id}</id>
|
||||||
|
<link rel="self" href="${absurl(url.full)?xml}" type="${format.type}"/>
|
||||||
|
<@parent node=node.parent recurse=returnToRoot/>
|
||||||
|
<#-- TODO: secondary parents loop -->
|
||||||
|
</feed>
|
||||||
|
|
||||||
|
<#macro parent node recurse=false>
|
||||||
|
<#if node?exists && node.isContainer>
|
||||||
|
<@entriesLib.folder node=node/>
|
||||||
|
<#if recurse>
|
||||||
|
<@parent node=node.parent recurse=true/>
|
||||||
|
</#if>
|
||||||
|
</#if>
|
||||||
|
</#macro>
|
@@ -0,0 +1,9 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Retrieve Parent Folders</shortname>
|
||||||
|
<description>Retrieve parent folders (primary and secondary)</description>
|
||||||
|
<!-- TODO: returnToRoot argument required? -->
|
||||||
|
<url>/api/node/{store_type}/{store_id}/{id}/parents</url>
|
||||||
|
<url>/api/path/{store_type}/{store_id}/{id}/parents</url>
|
||||||
|
<authentication>guest</authentication>
|
||||||
|
<format default="atomfeed">argument</format>
|
||||||
|
</webscript>
|
@@ -0,0 +1,21 @@
|
|||||||
|
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: property filters
|
||||||
|
|
||||||
|
// TODO: check returnToRoot is required for getDocumentParents
|
||||||
|
// retrieve parent
|
||||||
|
var returnToRoot = cmis.findArg(args.returnToRoot, headers["CMIS-returnToRoot"]);
|
||||||
|
model.returnToRoot = returnToRoot == "true" ? true : false;
|
||||||
|
}
|
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/CMIS/1.0" xmlns:alf="http://www.alfresco.org" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
|
||||||
|
<generator version="${server.version}">Alfresco (${server.edition})</generator>
|
||||||
|
<title>Unfiled Documents</title>
|
||||||
|
<updated>${xmldate(date)}</updated>
|
||||||
|
<icon>${absurl(url.context)}/images/logo/AlfrescoLogo16.ico</icon>
|
||||||
|
<author>
|
||||||
|
<name>System</name>
|
||||||
|
</author>
|
||||||
|
<id>urn:uuid:unfiled</id>
|
||||||
|
<link rel="self" href="${absurl(url.full)?xml}" type="${format.type}"/>
|
||||||
|
<#-- NOTE: Alfresco does not yet support unfiled documents -->
|
||||||
|
</feed>
|
@@ -0,0 +1,7 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>Unfiled Documents</shortname>
|
||||||
|
<description>Retrieve list of documents that are not in any folder</description>
|
||||||
|
<url>/api/unfiled</url>
|
||||||
|
<authentication>guest</authentication>
|
||||||
|
<format default="atomfeed"/>
|
||||||
|
</webscript>
|
@@ -149,6 +149,8 @@
|
|||||||
<property name="searchService" ref="searchService" />
|
<property name="searchService" ref="searchService" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="webscripts.cmis.description" class="org.alfresco.repo.cmis.CMISDescription"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- Web Script Javascript Extensions -->
|
<!-- Web Script Javascript Extensions -->
|
||||||
@@ -403,5 +405,14 @@
|
|||||||
|
|
||||||
<!-- Switch on debugger by setting log4j.logger.org.alfresco.repo.web.scripts.AlfrescoRhinoScriptDebugger to DEBUG -->
|
<!-- Switch on debugger by setting log4j.logger.org.alfresco.repo.web.scripts.AlfrescoRhinoScriptDebugger to DEBUG -->
|
||||||
<bean id="rhinoScriptDebugger" class="org.alfresco.repo.web.scripts.AlfrescoRhinoScriptDebugger" init-method="start"/>
|
<bean id="rhinoScriptDebugger" class="org.alfresco.repo.web.scripts.AlfrescoRhinoScriptDebugger" init-method="start"/>
|
||||||
|
<!-- -->
|
||||||
|
<!-- CMIS API -->
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
|
<alias alias="webscriptdesc.org.alfresco.repository.repository.get" name="webscripts.cmis.description"/>
|
||||||
|
<alias alias="webscriptdesc.org.alfresco.repository.store.children.get" name="webscripts.cmis.description"/>
|
||||||
|
<alias alias="webscriptdesc.org.alfresco.repository.store.parent.get" name="webscripts.cmis.description"/>
|
||||||
|
<alias alias="webscriptdesc.org.alfresco.repository.store.parents.get" name="webscripts.cmis.description"/>
|
||||||
|
<alias alias="webscriptdesc.org.alfresco.repository.store.unfiled.get" name="webscripts.cmis.description"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
80
source/java/org/alfresco/repo/cmis/CMISDescription.java
Normal file
80
source/java/org/alfresco/repo/cmis/CMISDescription.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.web.scripts.DescriptionExtension;
|
||||||
|
import org.alfresco.web.scripts.WebScriptException;
|
||||||
|
import org.dom4j.Document;
|
||||||
|
import org.dom4j.DocumentException;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
import org.dom4j.io.SAXReader;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web Script Descriptor Extension
|
||||||
|
*
|
||||||
|
* <cmis version="x"/>
|
||||||
|
*
|
||||||
|
* @author davidc
|
||||||
|
*/
|
||||||
|
public class CMISDescription implements DescriptionExtension
|
||||||
|
{
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.web.scripts.DescriptionExtension#parseExtensions(java.lang.String, java.io.InputStream)
|
||||||
|
*/
|
||||||
|
public Map<String, Serializable> parseExtensions(String serviceDescPath, InputStream serviceDesc)
|
||||||
|
{
|
||||||
|
SAXReader reader = new SAXReader();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Map<String, Serializable> extensions = null;
|
||||||
|
Document document = reader.read(serviceDesc);
|
||||||
|
Element rootElement = document.getRootElement();
|
||||||
|
Element cmisElement = rootElement.element("cmis");
|
||||||
|
if (cmisElement != null)
|
||||||
|
{
|
||||||
|
extensions = new HashMap<String, Serializable>();
|
||||||
|
String version = cmisElement.attributeValue("version");
|
||||||
|
if (version == null || version.length() == 0)
|
||||||
|
{
|
||||||
|
throw new WebScriptException("Expected 'version' attribute on <cmis> element");
|
||||||
|
}
|
||||||
|
extensions.put("cmis_version", version);
|
||||||
|
}
|
||||||
|
return extensions;
|
||||||
|
}
|
||||||
|
catch(DocumentException e)
|
||||||
|
{
|
||||||
|
throw new WebScriptException("Failed to parse web script description document " + serviceDescPath, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user