Merge Web Scripts from BRANCHES/DEV/DAVE

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5355 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2007-03-08 14:51:33 +00:00
parent bea1a12b32
commit 4b30804f20
24 changed files with 882 additions and 123 deletions

View File

@@ -3,7 +3,7 @@
<generator version="${server.version}">Alfresco (${server.edition})</generator>
<title>Alfresco Keyword Search: ${search.searchTerms}</title>
<updated>${xmldate(date)}</updated>
<icon>${absurl("/images/logo/AlfrescoLogo16.ico")}</icon>
<icon>${absurl(url.context)}/images/logo/AlfrescoLogo16.ico</icon>
<author>
<name><#if person??>${person.properties.userName}<#else>unknown</#if></name>
</author>
@@ -12,22 +12,22 @@
<opensearch:startIndex>${search.startIndex}</opensearch:startIndex>
<opensearch:itemsPerPage>${search.itemsPerPage}</opensearch:itemsPerPage>
<opensearch:Query role="request" searchTerms="${search.searchTerms}" startPage="${search.startPage}" count="${search.itemsPerPage}" language="${search.localeId}"/>
<link rel="alternate" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.startPage}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=html" type="text/html"/>
<link rel="self" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.startPage}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
<link rel="alternate" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.startPage}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=html" type="text/html"/>
<link rel="self" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.startPage}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
<#if search.startPage &gt; 1>
<link rel="first" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=1&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
<link rel="previous" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.startPage - 1}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
<link rel="first" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=1&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
<link rel="previous" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.startPage - 1}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
</#if>
<#if search.startPage &lt; search.totalPages>
<link rel="next" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.startPage + 1}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
<link rel="last" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.totalPages}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
<link rel="next" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.startPage + 1}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
<link rel="last" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.totalPages}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=atom" type="application/atom+xml"/>
</#if>
<link rel="search" type="application/opensearchdescription+xml" href="${path.serviceContext}/search/keyword/description.xml"/>
<link rel="search" type="application/opensearchdescription+xml" href="${absurl(url.service)}/description.xml"/>
<#list search.results as row>
<entry>
<title>${row.name}</title>
<link rel="alternate" href="${absurl(row.url)}"/>
<icon>${absurl(row.icon16)}</icon> <#comment>TODO: What's the standard for entry icons?</#comment>
<link rel="alternate" href="${absurl(url.context)}${row.url}"/>
<icon>${absurl(url.context)}${row.icon16}</icon> <#comment>TODO: What's the standard for entry icons?</#comment>
<id>urn:uuid:${row.id}</id>
<updated>${xmldate(row.properties.modified)}</updated>
<summary>${row.properties.description!""}</summary>

View File

@@ -4,7 +4,7 @@
<head profile="http://a9.com/-/spec/opensearch/1.1/">
<title>Alfresco Keyword Search: ${search.searchTerms}</title>
<link rel="stylesheet" href="/alfresco/css/main.css" TYPE="text/css">
<link rel="search" type="application/opensearchdescription+xml" href="${path.serviceContext}/search/keyword/description.xml" title="Alfresco Keyword Search"/>
<link rel="search" type="application/opensearchdescription+xml" href="${url.service}/description.xml" title="Alfresco Keyword Search"/>
<meta name="totalResults" content="${search.totalResults}"/>
<meta name="startIndex" content="${search.startIndex}"/>
<meta name="itemsPerPage" content="${search.itemsPerPage}"/>
@@ -12,7 +12,7 @@
<body>
<table>
<tr>
<td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Keyword Search</span></nobr></td>
</tr>
</table>
@@ -26,7 +26,7 @@
<table>
<#list search.results as row>
<tr>
<td><img src="${absurl(row.icon16)}"/></td><td><a href="${absurl(row.url)}">${row.name}</a></td>
<td><img src="${url.context}${row.icon16}"/></td><td><a href="${url.context}${row.url}">${row.name}</a></td>
</tr>
<#if row.properties.description?? == true>
<tr>
@@ -39,15 +39,15 @@
<br>
<table>
<tr>
<td><a href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&p=1&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">first</a></td>
<td><a href="${url.service}?q=${search.searchTerms?url}&p=1&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">first</a></td>
<#if search.startPage &gt; 1>
<td><a href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&p=${search.startPage - 1}&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">previous</a></td>
<td><a href="${url.service}?q=${search.searchTerms?url}&p=${search.startPage - 1}&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">previous</a></td>
</#if>
<td><a href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&p=${search.startPage}&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">${search.startPage}</a></td>
<td><a href="${url.service}?q=${search.searchTerms?url}&p=${search.startPage}&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">${search.startPage}</a></td>
<#if search.startPage &lt; search.totalPages>
<td><a href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&p=${search.startPage + 1}&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">next</a></td>
<td><a href="${url.service}?q=${search.searchTerms?url}&p=${search.startPage + 1}&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">next</a></td>
</#if>
<td><a href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&p=${search.totalPages}&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">last</a></td>
<td><a href="${url.service}?q=${search.searchTerms?url}&p=${search.totalPages}&c=${search.itemsPerPage}&l=${search.localeId}&guest=${guest?string("true","")}">last</a></td>
</tr>
</table>
</body>

View File

@@ -2,7 +2,7 @@
<rss version="2.0" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Alfresco Keyword Search: ${search.searchTerms}</title>
<link>${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.startPage}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss</link>
<link>${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.startPage}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss</link>
<description>Alfresco Keyword Search: ${search.searchTerms}</description>
<language>${search.localeId}</language>
<lastBuildDate>${xmldate(date)}</lastBuildDate>
@@ -12,26 +12,26 @@
<title>Alfresco Search: ${search.searchTerms}</title>
<width>16</width>
<height>16</height>
<url>${absurl("/images/logo/AlfrescoLogo16.ico")}</url>
<url>${absurl(url.context)}/images/logo/AlfrescoLogo16.ico)}</url>
</image>
<opensearch:totalResults>${search.totalResults}</opensearch:totalResults>
<opensearch:startIndex>${search.startIndex}</opensearch:startIndex>
<opensearch:itemsPerPage>${search.itemsPerPage}</opensearch:itemsPerPage>
<opensearch:Query role="request" searchTerms="${search.searchTerms}" startPage="${search.startPage}" count="${search.itemsPerPage}" language="${search.localeId}"/>
<atom:link rel="self" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.startPage}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
<atom:link rel="self" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.startPage}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
<#if search.startPage &gt; 1>
<atom:link rel="first" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=1&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
<atom:link rel="previous" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.startPage - 1}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
<atom:link rel="first" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=1&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
<atom:link rel="previous" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.startPage - 1}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
</#if>
<#if search.startPage &lt; search.totalPages>
<atom:link rel="next" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.startPage + 1}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
<atom:link rel="last" href="${path.serviceContext}/search/keyword?q=${search.searchTerms?url}&amp;p=${search.totalPages}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
<atom:link rel="next" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.startPage + 1}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
<atom:link rel="last" href="${absurl(url.service)}?q=${search.searchTerms?url}&amp;p=${search.totalPages}&amp;c=${search.itemsPerPage}&amp;l=${search.localeId}&amp;guest=${guest?string("true","")}&amp;format=rss" type="application/atom+xml"/>
</#if>
<atom:link rel="search" type="application/opensearchdescription+xml" href="${path.serviceContext}/search/keyword/description.xml"/>
<atom:link rel="search" type="application/opensearchdescription+xml" href="${absurl(url.service)}/description.xml"/>
<#list search.results as row>
<item>
<title>${row.name}</title>
<link>${absurl(row.url)}</link>
<link>${absurl(url.context)}${row.url}</link>
<description>${row.properties.description!""}</description>
<pubDate>${xmldate(row.properties.modified)}</pubDate>
<guid isPermaLink="false">${row.id}</guid>

View File

@@ -4,8 +4,8 @@
<LongName>Alfresco ${server.edition} Keyword Search ${server.version}</LongName>
<Description>Search Alfresco "company home" using keywords</Description>
<#comment>IE takes first template from list, thus html response is listed first</#comment>
<Url type="text/html" template="${path.serviceContext}/search/keyword?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}&amp;guest={alf:guest?}"/>
<Url type="application/atom+xml" template="${path.serviceContext}/search/keyword?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}&amp;guest={alf:guest?}&amp;format=atom"/>
<Url type="application/rss+xml" template="${path.serviceContext}/search/keyword?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}&amp;guest={alf:guest?}&amp;format=rss"/>
<Image height="16" width="16" type="image/x-icon">${path.context}/images/logo/AlfrescoLogo16.ico</Image>
<Url type="text/html" template="${absurl(url.serviceContext)}/search/keyword?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}&amp;guest={alf:guest?}"/>
<Url type="application/atom+xml" template="${absurl(url.serviceContext)}/search/keyword?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}&amp;guest={alf:guest?}&amp;format=atom"/>
<Url type="application/rss+xml" template="${absurl(url.serviceContext)}/search/keyword?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}&amp;guest={alf:guest?}&amp;format=rss"/>
<Image height="16" width="16" type="image/x-icon">${absurl(url.context)}/images/logo/AlfrescoLogo16.ico</Image>
</OpenSearchDescription>

View File

@@ -3,17 +3,17 @@
<generator version="${server.version}">Alfresco (${server.edition})</generator>
<title>Registered Search Engines</title>
<updated>${xmldate(date)}</updated>
<icon>${path.context}/images/logo/AlfrescoLogo16.ico</icon>
<icon>${absurl(url.context)}/images/logo/AlfrescoLogo16.ico</icon>
<author>
<name><#if person??>${person.properties.userName}<#else>unknown</#if></name>
</author>
<id>${path.service?xml}</id>
<id>${absurl(url.full)?xml}</id>
<#list engines as engine>
<entry>
<title>${engine.label}</title>
<link rel="alternate" type="${engine.type}" href="${absurl(engine.url)?xml}" title="${engine.label}"/>
<link rel="alternate" type="${engine.type}" href="${absurl(url.context)}${engine.url)?xml}" title="${engine.label}"/>
<summary><#if engine.urlType == "description">OpenSearch Description<#else>Template URL</#if> - ${engine.type}</summary>
<id>${absurl(engine.url)?xml}</id>
<id>${absurl(url.context)}${engine.url)?xml}</id>
<updated>${xmldate(date)}</updated>
</entry>
</#list>

View File

@@ -2,18 +2,18 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://a9.com/-/spec/opensearch/1.1/">
<link rel="stylesheet" href="/alfresco/css/main.css" TYPE="text/css">
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
<title>Alfresco Registered Search Engines</title>
<#list engines as engine>
<#if engine.urlType == "description">
<link rel="search" type="${engine.type}" href="${absurl(engine.url)}" title="${engine.label}">
<link rel="search" type="${engine.type}" href="${url.context}${engine.url}" title="${engine.label}">
</#if>
</#list>
</head>
<body>
<table>
<tr>
<td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Registered Search Engines</span></nobr></td>
</tr>
</table>
@@ -22,7 +22,7 @@
<tr align="left"><td><b>Engine<td><b>URL Type<td><b>Response Format</tr>
<#list engines as engine>
<tr align="left">
<td><a href="${absurl(engine.url)}">${engine.label}</a>
<td><a href="${url.context}${engine.url}">${engine.label}</a>
<td><#if engine.urlType == "description">OpenSearch Description<#else>Template URL</#if>
<td>${engine.type}
</tr>

View File

@@ -3,15 +3,15 @@
<generator version="${server.version}">Alfresco (${server.edition})</generator>
<title>Alfresco Keyword Search: ${args.q}</title>
<updated>${xmldate(date)}</updated>
<icon>${absurl("/images/logo/AlfrescoLogo16.ico")}</icon>
<icon>${absurl(url.context)}/images/logo/AlfrescoLogo16.ico</icon>
<author>
<name><#if person??>${person.properties.userName}<#else>unknown</#if></name>
</author>
<#list resultset as node>
<entry>
<title>${node.name}</title>
<link rel="alternate" href="${node.url}"/>
<icon>${node.icon16}</icon>
<link rel="alternate" href="${absurl(url.context)}${node.url}"/>
<icon>${absurl(url.context)}${node.icon16}</icon>
<id>urn:uuid:${node.id}</id>
<updated>${xmldate(node.properties.modified)}</updated>
<summary>${node.properties.description!""}</summary>

View File

@@ -3,12 +3,12 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Alfresco Keyword Search: ${args.q}</title>
<link rel="stylesheet" href="/alfresco/css/main.css" TYPE="text/css">
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<table>
<tr>
<td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Keyword Search: ${args.q}</span></nobr></td>
</tr>
</table>
@@ -16,7 +16,7 @@
<table>
<#list resultset as node>
<tr>
<td><img src="${node.icon16}"/></td><td><a href="${node.url}">${node.name}</a></td>
<td><img src="${url.context}${node.icon16}"/></td><td><a href="${url.context}${node.url}">${node.name}</a></td>
</tr>
<#if node.properties.description?? == true>
<tr>

View File

@@ -3,27 +3,31 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Alfresco Web APIs</title>
<link rel="stylesheet" href="/alfresco/css/main.css" TYPE="text/css">
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<table>
<tr>
<td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Web APIs</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
<tr><td><td>${services?size} services - <a href="http://wiki.alfresco.com/wiki/REST">Online documentation</a>.
</table>
<form action="${url.match}" method="post">
<input type="hidden" name="reset" value="on">
<table>
<tr>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Web APIs</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
<tr><td><td>${services?size} apis - <a href="http://wiki.alfresco.com/wiki/REST">Online documentation</a>. <input type="submit" name="submit" value="Refresh list of Web APIs">
</table>
</form>
<br>
<br>
<table border="0" cellpadding="4">
<tr align="left"><td><b>Id<td><b>Method<td><b>Authentication</tr>
<#list services as service>
<#assign desc = service.description>
<tr><td>${desc.id}<td>${desc.method}<td>${desc.requiredAuthentication}</tr>
<tr><td colspan="4">&nbsp;&nbsp;[${desc.description}]</tr>
<tr><td colspan="4"></tr>
<tr><td colspan="3">&nbsp;&nbsp;[${desc.description}]</tr>
<tr><td colspan="3"></tr>
<#list desc.URIs as uri>
<tr><td>&nbsp;&nbsp;${uri.format}<#if uri.format = desc.defaultFormat> (default)</#if><td colspan="3"><a href="${path.serviceContext}${uri.URI}">${path.serviceContext}${uri.URI}</a></tr>
<tr><td>&nbsp;&nbsp;${uri.format}<#if uri.format = desc.defaultFormat> (default)</#if><td colspan="3"><a href="${url.serviceContext}${uri.URI}">${url.serviceContext}${uri.URI}</a></tr>
</#list>
</#list>
</table>

View File

@@ -0,0 +1,5 @@
<servicedescription>
<shortname>Service Index Maintenance</shortname>
<description>Maintain index of Web API Services</description>
<url format="html" template="/index?reset={reset?}" />
</servicedescription>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Alfresco Web APIs Maintenance</title>
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<table>
<tr>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Web APIs Maintenance</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
<tr><td><td><a href="${url.match}">${services?size} apis</a>.
</table>
<br>
<table border="0" cellpadding="4">
<tr align="left"><td><b>Completed Task</tr>
<#list tasks as task>
<tr><td>${task}<td></tr>
</#list>
</table>
</html>

View File

@@ -30,13 +30,25 @@
<property name="scriptService" ref="ScriptService" />
</bean>
<!-- TODO: Provide abstract definitions for repo & class path stores -->
<!-- TODO: Define repo web folder for API templates + appropriate patches -->
<!-- TODO: Provide repo extension, classpath extension, repo, classpath search order -->
<!--
<bean id="web.api.framework.store.repopath" class="org.alfresco.web.api.framework.RepoPathAPIStore">
<property name="transactionService" ref="transactionComponent" />
<property name="nodeService" ref="nodeService" />
<property name="namespaceService" ref="namespaceService" />
<property name="contentService" ref="contentService" />
<property name="searchService" ref="SearchService" />
<property name="store"><value>workspace://SpacesStore</value></property>
<property name="path"><value>/app:company_home/app:dictionary/cm:WebAPI</value></property>
</bean>
-->
<bean id="web.api.framework.store.classpath" class="org.alfresco.web.api.framework.ClassPathAPIStore">
<property name="classPath"><value>alfresco/templates/web/api</value></property>
</bean>
<!-- TODO: classpath extension directory -->
<!-- TODO: repository paths -->
<!-- -->
<!-- API Service Registry -->
@@ -156,6 +168,9 @@
<!-- List of available Web APIs -->
<bean id="web.api.org.alfresco.service.index_get" class="org.alfresco.web.api.Index" parent="web.api.framework.service" />
<!-- Maintain list of available Web APIs -->
<bean id="web.api.org.alfresco.service.index_post" class="org.alfresco.web.api.IndexUpdate" parent="web.api.framework.service" />
<!-- List of registered (OpenSearch) search engines -->
<bean id="web.api.org.alfresco.repository.searchengines_get" class="org.alfresco.web.api.SearchEngines" parent="web.api.framework.service">
<property name="configService" ref="web.api.framework.config" />

View File

@@ -0,0 +1,69 @@
/*
* 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.web.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.web.api.framework.APIRequest;
import org.alfresco.web.api.framework.APIResponse;
import org.alfresco.web.api.framework.ScriptedAPIService;
/**
* Retrieves the list of available Web APIs
*
* @author davidc
*/
public class IndexUpdate extends ScriptedAPIService
{
/* (non-Javadoc)
* @see org.alfresco.web.api.services.APIServiceTemplateImpl#createModel(org.alfresco.web.api.APIRequest, org.alfresco.web.api.APIResponse, java.util.Map)
*/
@Override
protected Map<String, Object> executeImpl(APIRequest req, APIResponse res)
{
List<String> tasks = new ArrayList<String>();
// reset index
String reset = req.getParameter("reset");
if (reset != null && reset.equals("on"))
{
int previousCount = getAPIRegistry().getServices().size();
getAPIRegistry().reset();
tasks.add("Reset Web API Registry; found " + getAPIRegistry().getServices().size() + " APIs. Previously, there were " + previousCount + ".");
}
// create model for rendering
Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
model.put("tasks", tasks);
model.put("services", getAPIRegistry().getServices());
return model;
}
}

View File

@@ -164,7 +164,7 @@ public class SearchProxy extends AbstractAPIService implements InitializingBean
logger.debug("Mapping engine '" + engine + "' (mimetype '" + mimetype + "') to url '" + engineUrl + "'");
// issue request against search engine
SearchEngineHttpProxy proxy = new SearchEngineHttpProxy(req.getPath(), engine, engineUrl, res);
SearchEngineHttpProxy proxy = new SearchEngineHttpProxy(req.getServicePath() + "/" + req.getContextPath(), engine, engineUrl, res);
proxy.service();
}

View File

@@ -87,4 +87,9 @@ public interface APIRegistry
* @return script processor
*/
public APIScriptProcessor getScriptProcessor();
/**
* Resets the API Registry
*/
public void reset();
}

View File

@@ -27,8 +27,6 @@ package org.alfresco.web.api.framework;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
/**
* API Service Request
@@ -64,23 +62,45 @@ public class APIRequest extends HttpServletRequestWrapper
}
/**
* Gets the Alfresco Context URL
* Get server portion of the request
*
* @return context url e.g. http://localhost:port/alfresco
* e.g. scheme://host:port
*
* @return server path
*/
public String getPath()
public String getServerPath()
{
return getScheme() + "://" + getServerName() + ":" + getServerPort() + getContextPath();
return getScheme() + "://" + getServerName() + ":" + getServerPort();
}
/**
* Gets the Alfresco Service URL
* Gets the Alfresco Service Context Path
*
* @return service url e.g. http://localhost:port/alfresco/service
* @return service url e.g. /alfresco/service
*/
public String getServiceContextPath()
{
return getContextPath() + getServletPath();
}
/**
* Gets the Alfresco Service Path
*
* @return service url e.g. /alfresco/service/search/keyword
*/
public String getServicePath()
{
return getPath() + getServletPath();
return getServiceContextPath() + getPathInfo();
}
/**
* Gets the full request URL
*
* @return request url e.g. /alfresco/service/search/keyword?q=term
*/
public String getURL()
{
return getServicePath() + (getQueryString() != null ? "?" + getQueryString() : "");
}
/**
@@ -107,26 +127,6 @@ public class APIRequest extends HttpServletRequestWrapper
return extensionPath;
}
/**
* Gets the full request URL
*
* @return request url e.g. http://localhost:port/alfresco/service/keyword?q=term
*/
public String getUrl()
{
return getScheme() + "://" + getServerName() + ":" + getServerPort() + getPathInfo() + (getQueryString() != null ? "?" + getQueryString() : "");
}
/**
* Gets the currently authenticated username
*
* @return username
*/
public String getAuthenticatedUsername()
{
return AuthenticationUtil.getCurrentUserName();
}
/**
* Determine if Guest User?
*

View File

@@ -108,4 +108,12 @@ public class APIScriptProcessor
return scriptService.executeScript(location, model);
}
/**
* Reset script cache
*/
public void resetCache()
{
// NOOP
}
}

View File

@@ -83,6 +83,17 @@ public class APITemplateProcessor extends FreeMarkerProcessor implements Applica
this.templateLoader = templateLoader;
}
/**
* Reset template cache
*/
public void resetCache()
{
if (templateConfig != null)
{
templateConfig.clearTemplateCache();
}
}
/**
* Initialise FreeMarker Configuration
*/

View File

@@ -218,7 +218,7 @@ public abstract class AbstractAPIService implements APIService
// add api context
model.put("args", createArgModel(req));
model.put("guest", req.isGuest());
model.put("path", new PathModel(req));
model.put("url", new URLModel(req));
model.put("server", new ServerModel(descriptorService.getServerDescriptor()));
// add custom model
@@ -265,12 +265,12 @@ public abstract class AbstractAPIService implements APIService
// add api context
model.put("args", createArgModel(req));
model.put("guest", req.isGuest());
model.put("path", new PathModel(req));
model.put("url", new URLModel(req));
model.put("server", new ServerModel(descriptorService.getServerDescriptor()));
// add template support
model.put("xmldate", new ISO8601DateFormatMethod());
model.put("absurl", new AbsoluteUrlMethod(req.getPath()));
model.put("absurl", new AbsoluteUrlMethod(req.getServerPath()));
model.put("urlencode", new UrlEncodeMethod());
model.put("date", new Date());

View File

@@ -53,8 +53,8 @@ import freemarker.cache.TemplateLoader;
public class ClassPathAPIStore implements APIStore, InitializingBean
{
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
private String classPath;
private File fileDir;
protected String classPath;
protected File fileDir;
/**
@@ -124,6 +124,10 @@ public class ClassPathAPIStore implements APIStore, InitializingBean
throws IOException
{
File document = new File(fileDir, documentPath);
if (!document.exists())
{
throw new IOException("Description document " + documentPath + " does not exist.");
}
return new FileInputStream(document);
}
@@ -149,7 +153,7 @@ public class ClassPathAPIStore implements APIStore, InitializingBean
*/
public ScriptLoader getScriptLoader()
{
return new ClassPathScriptLoader(fileDir);
return new ClassPathScriptLoader();
}
/**
@@ -159,17 +163,6 @@ public class ClassPathAPIStore implements APIStore, InitializingBean
*/
private class ClassPathScriptLoader implements ScriptLoader
{
private File classPath;
/**
* Construct
*
* @param classPath
*/
public ClassPathScriptLoader(File classPath)
{
this.classPath = classPath;
}
/* (non-Javadoc)
* @see org.alfresco.web.api.ScriptLoader#getScriptLocation(java.lang.String)
@@ -177,7 +170,7 @@ public class ClassPathAPIStore implements APIStore, InitializingBean
public ScriptLocation getScriptLocation(String path)
{
ScriptLocation location = null;
File scriptPath = new File(classPath, path);
File scriptPath = new File(fileDir, path);
if (scriptPath.exists())
{
location = new ClassPathScriptLocation(scriptPath);

View File

@@ -218,7 +218,7 @@ public class DeclarativeAPIRegistry implements APIRegistry, ApplicationContextAw
if (logger.isDebugEnabled())
{
APIService existingService = servicesById.get(id);
logger.debug("Service description document " + existingService.getDescription().getSourceLocation() + " overridden by " + serviceDesc.getSourceLocation());
logger.debug("Service description document " + serviceDesc.getSourceLocation() + " overridden by " + existingService.getDescription().getSourceLocation());
}
continue;
}
@@ -519,6 +519,16 @@ public class DeclarativeAPIRegistry implements APIRegistry, ApplicationContextAw
return this.stores.getScriptProcessor();
}
/* (non-Javadoc)
* @see org.alfresco.web.api.framework.APIRegistry#reset()
*/
public void reset()
{
getTemplateProcessor().resetCache();
getScriptProcessor().resetCache();
initServices();
}
/**
* API Service Match

View File

@@ -0,0 +1,578 @@
/*
* 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.web.api.framework;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.ScriptLocation;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.AbstractLifecycleBean;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import freemarker.cache.TemplateLoader;
/**
* Repository based API Store
*
* @author davidc
*/
public class RepoPathAPIStore implements APIStore, ApplicationContextAware, ApplicationListener
{
private ProcessorLifecycle lifecycle = new ProcessorLifecycle();
protected StoreRef repoStore;
protected String repoPath;
protected NodeRef baseNodeRef;
protected String baseDir;
// dependencies
protected TransactionService transactionService;
protected SearchService searchService;
protected NodeService nodeService;
protected ContentService contentService;
protected NamespaceService namespaceService;
/**
* Sets transaction service
*
* @param transactionService
*/
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
}
/**
* Sets the search service
*
* @param searchService
*/
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
/**
* Sets the node service
*
* @param nodeService
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* Sets the content service
*
* @param contentService
*/
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
/**
* Sets the namespace service
*
* @param namespaceService
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
/**
* Sets the repo store
*
* @param repoStore
*/
public void setStore(String repoStore)
{
this.repoStore = new StoreRef(repoStore);
}
/**
* Sets the repo path
*
* @param repoPath repoPath
*/
public void setPath(String repoPath)
{
this.repoPath = repoPath;
}
/* (non-Javadoc)
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
lifecycle.setApplicationContext(applicationContext);
}
/* (non-Javadoc)
* @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)
*/
public void onApplicationEvent(ApplicationEvent event)
{
lifecycle.onApplicationEvent(event);
}
/**
* Hooks into Spring Application Lifecycle
*/
private class ProcessorLifecycle extends AbstractLifecycleBean
{
@Override
protected void onBootstrap(ApplicationEvent event)
{
init();
}
@Override
protected void onShutdown(ApplicationEvent event)
{
}
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
protected void init()
{
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
public Object doWork() throws Exception
{
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<Object>()
{
public Object doWork() throws Exception
{
String query = "PATH:\"" + repoPath + "\"";
ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query);
if (resultSet.length() == 0)
{
throw new APIException("Unable to locate repository path " + repoStore.toString() + repoPath);
}
if (resultSet.length() > 1)
{
throw new APIException("Multiple repository paths found for " + repoStore.toString() + repoPath);
}
baseNodeRef = resultSet.getNodeRef(0);
baseDir = getPath(baseNodeRef);
return null;
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
/* (non-Javadoc)
* @see org.alfresco.web.api.APIStore#getBasePath()
*/
public String getBasePath()
{
return repoStore.toString() + repoPath;
}
/**
* Gets the display path for the specified node
*
* @param nodeRef
* @return display path
*/
protected String getPath(NodeRef nodeRef)
{
return nodeService.getPath(nodeRef).toDisplayPath(nodeService) + "/" + nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
}
/**
* Gets the node ref for the specified path within this repo store
*
* @param documentPath
* @return node ref
*/
protected NodeRef findNodeRef(String documentPath)
{
StringBuilder xpath = new StringBuilder(documentPath.length() << 1);
for (StringTokenizer t = new StringTokenizer(documentPath, "/"); t.hasMoreTokens(); /**/)
{
if (xpath.length() != 0)
{
xpath.append('/');
}
xpath.append("*[@cm:name='").append(t.nextToken()).append("']");
}
List<NodeRef> nodes = searchService.selectNodes(baseNodeRef, xpath.toString(), null, namespaceService, false);
return (nodes.size() == 1) ? nodes.get(0) : null;
}
/* (non-Javadoc)
* @see org.alfresco.web.api.APIStore#getDescriptionDocumentPaths()
*/
public String[] getDescriptionDocumentPaths()
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String[]>()
{
public String[] doWork() throws Exception
{
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<String[]>()
{
public String[] doWork() throws Exception
{
int baseDirLength = baseDir.length() +1;
List<String> documentPaths = new ArrayList<String>();
String query = "PATH:\"" + repoPath + "//*\" AND @cm\\:name:\"*_desc.xml\"";
ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query);
List<NodeRef> nodes = resultSet.getNodeRefs();
for (NodeRef nodeRef : nodes)
{
String nodeDir = getPath(nodeRef);
String documentPath = nodeDir.substring(baseDirLength);
documentPaths.add(documentPath);
}
return documentPaths.toArray(new String[documentPaths.size()]);
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
/* (non-Javadoc)
* @see org.alfresco.web.api.APIStore#getDescriptionDocument(java.lang.String)
*/
public InputStream getDescriptionDocument(final String documentPath)
throws IOException
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<InputStream>()
{
public InputStream doWork() throws Exception
{
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<InputStream>()
{
public InputStream doWork() throws Exception
{
NodeRef nodeRef = findNodeRef(documentPath);
if (nodeRef == null)
{
throw new IOException("Description document " + documentPath + " does not exist.");
}
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
return reader.getContentInputStream();
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
/* (non-Javadoc)
* @see org.alfresco.web.api.APIStore#getTemplateLoader()
*/
public TemplateLoader getTemplateLoader()
{
return new RepoTemplateLoader();
}
/* (non-Javadoc)
* @see org.alfresco.web.api.APIStore#getScriptLoader()
*/
public ScriptLoader getScriptLoader()
{
return new RepoScriptLoader();
}
/**
* Repository path based template loader
*
* @author davidc
*/
private class RepoTemplateLoader implements TemplateLoader
{
/* (non-Javadoc)
* @see freemarker.cache.TemplateLoader#findTemplateSource(java.lang.String)
*/
public Object findTemplateSource(final String name)
throws IOException
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
public Object doWork() throws Exception
{
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<Object>()
{
public Object doWork() throws Exception
{
RepoTemplateSource source = null;
NodeRef nodeRef = findNodeRef(name);
if (nodeRef != null)
{
source = new RepoTemplateSource(nodeRef);
}
return source;
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
/* (non-Javadoc)
* @see freemarker.cache.TemplateLoader#getLastModified(java.lang.Object)
*/
public long getLastModified(Object templateSource)
{
return ((RepoTemplateSource)templateSource).lastModified();
}
/* (non-Javadoc)
* @see freemarker.cache.TemplateLoader#getReader(java.lang.Object, java.lang.String)
*/
public Reader getReader(Object templateSource, String encoding) throws IOException
{
return ((RepoTemplateSource)templateSource).getReader();
}
/* (non-Javadoc)
* @see freemarker.cache.TemplateLoader#closeTemplateSource(java.lang.Object)
*/
public void closeTemplateSource(Object arg0) throws IOException
{
}
}
/**
* Repository (content) node template source
*
* @author davidc
*/
private class RepoTemplateSource
{
protected final NodeRef nodeRef;
/**
* Construct
*
* @param ref
*/
private RepoTemplateSource(NodeRef ref)
{
this.nodeRef = ref;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object o)
{
if (o instanceof RepoTemplateSource)
{
return nodeRef.equals(((RepoTemplateSource)o).nodeRef);
}
else
{
return false;
}
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode()
{
return nodeRef.hashCode();
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString()
{
return nodeRef.toString();
}
/**
* Gets the last modified time of the content
*
* @return last modified time
*/
public long lastModified()
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Long>()
{
public Long doWork() throws Exception
{
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<Long>()
{
public Long doWork() throws Exception
{
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
return reader.getLastModified();
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
/**
* Gets the content reader
*
* @return content reader
* @throws IOException
*/
public Reader getReader() throws IOException
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Reader>()
{
public Reader doWork() throws Exception
{
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<Reader>()
{
public Reader doWork() throws Exception
{
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
return new InputStreamReader(reader.getContentInputStream());
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
}
/**
* Repository path based script loader
*
* @author davidc
*/
private class RepoScriptLoader implements ScriptLoader
{
/* (non-Javadoc)
* @see org.alfresco.web.api.ScriptLoader#getScriptLocation(java.lang.String)
*/
public ScriptLocation getScriptLocation(final String path)
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<ScriptLocation>()
{
public ScriptLocation doWork() throws Exception
{
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<ScriptLocation>()
{
public ScriptLocation doWork() throws Exception
{
ScriptLocation location = null;
NodeRef nodeRef = findNodeRef(path);
if (nodeRef != null)
{
location = new RepoScriptLocation(path, nodeRef);
}
return location;
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
}
/**
* Repo path script location
*
* @author davidc
*/
private class RepoScriptLocation implements ScriptLocation
{
protected String path;
protected NodeRef nodeRef;
/**
* Construct
*
* @param location
*/
public RepoScriptLocation(String path, NodeRef nodeRef)
{
this.path = path;
this.nodeRef = nodeRef;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.repository.ScriptLocation#getInputStream()
*/
public InputStream getInputStream()
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<InputStream>()
{
public InputStream doWork() throws Exception
{
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<InputStream>()
{
public InputStream doWork() throws Exception
{
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
return reader.getContentInputStream();
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.repository.ScriptLocation#getReader()
*/
public Reader getReader()
{
return new InputStreamReader(getInputStream());
}
@Override
public String toString()
{
return repoStore + "/" + baseDir + "/" + path;
}
}
}

View File

@@ -299,12 +299,11 @@ public class TestAPIServer
}
}
// set path info
// set paths
req.setContextPath("/alfresco");
req.setServletPath("/service");
req.setPathInfo(iArgIndex == -1 ? uri : uri.substring(0, iArgIndex));
// set servlet path
req.setServletPath("/alfresco/service");
return req;
}

View File

@@ -26,11 +26,11 @@ package org.alfresco.web.api.framework;
/**
* Script / Template Model representing API paths
* Script / Template Model representing API Service URLs
*
* @author davidc
*/
public class PathModel
public class URLModel
{
private APIRequest req;
@@ -39,7 +39,7 @@ public class PathModel
*
* @param req
*/
/*package*/ PathModel(APIRequest req)
URLModel(APIRequest req)
{
this.req = req;
}
@@ -47,13 +47,13 @@ public class PathModel
/**
* Gets the Context Path
*
* e.g. http://localhost:port/alfresco
* e.g. /alfresco
*
* @return context path
*/
public String getContext()
{
return req.getPath();
return req.getContextPath();
}
public String jsGet_context()
@@ -64,13 +64,13 @@ public class PathModel
/**
* Gets the Service Context Path
*
* e.g. http://localhost:port/alfresco/service
* e.g. /alfresco/service
*
* @return service context path
*/
public String getServiceContext()
{
return req.getServicePath();
return req.getServiceContextPath();
}
public String jsGet_serviceContext()
@@ -81,13 +81,13 @@ public class PathModel
/**
* Gets the Service Path
*
* e.g. http://localhost:port/alfresco/service/keyword?q=term
* e.g. /alfresco/service/search/keyword
*
* @return service path
*/
public String getService()
{
return req.getUrl();
return req.getServicePath();
}
public String jsGet_service()
@@ -95,6 +95,44 @@ public class PathModel
return getService();
}
/**
* Gets the full path
*
* e.g. /alfresco/service/search/keyword?q=term
*
* @return service path
*/
public String getFull()
{
return req.getURL();
}
public String jsGet_full()
{
return getFull();
}
/**
* Gets the matching service path
*
* e.g.
* a) service registered path = /search/engine
* b) request path = /search/engine/external
*
* => /search/engine
*
* @return matching path
*/
public String getMatch()
{
return getServiceContext() + req.getServiceMatch().getPath();
}
public String jsGet_match()
{
return getMatch();
}
/**
* Gets the Service Extension Path
*