mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Web Scripts:
- simplify how web scripts urls & formats are described - fix 'reset' on index page (when accessed via /) - fix xml status response (rogue html in template) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5897 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<webscript>
|
||||
<shortname>Web Scripts Documentation</shortname>
|
||||
<description>Web Scripts Documentation</description>
|
||||
<url format="html" template="/" />
|
||||
<url format="html" template="/index" />
|
||||
<url>/</url>
|
||||
<url>/index</url>
|
||||
</webscript>
|
@@ -1,5 +1,6 @@
|
||||
<webscript>
|
||||
<shortname>Web Script Maintenance</shortname>
|
||||
<description>Maintain index of Web Scripts</description>
|
||||
<url format="html" template="/index?reset={reset?}" />
|
||||
<url>/index?reset={reset?}</url>
|
||||
<url>/?reset={reset?}</url>
|
||||
</webscript>
|
@@ -1,6 +1,6 @@
|
||||
<webscript>
|
||||
<shortname>All Web Scripts Index</shortname>
|
||||
<description>Retrieve an index of all Web Scripts</description>
|
||||
<url format="html" template="/index/all" />
|
||||
<url format="mediawiki" template="/index/all.mediawiki" />
|
||||
<url>/index/all</url>
|
||||
<url>/index/all.mediawiki</url>
|
||||
</webscript>
|
@@ -27,7 +27,7 @@
|
||||
<span class="mainSubTitle">${desc.shortName}</span>
|
||||
<table>
|
||||
<#list desc.URIs as uri>
|
||||
<tr><td><a href="${url.serviceContext}${uri.URI}">${desc.method} ${url.serviceContext}${uri.URI}</a> => ${uri.format}<#if uri.format = desc.defaultFormat> (default)</#if>
|
||||
<tr><td><a href="${url.serviceContext}${uri}">${desc.method} ${url.serviceContext}${uri}</a>
|
||||
</#list>
|
||||
<tr><td>
|
||||
</table>
|
||||
@@ -36,6 +36,7 @@
|
||||
<tr><td>Authentication:<td>${desc.requiredAuthentication}
|
||||
<tr><td>Transaction:<td>${desc.requiredTransaction}
|
||||
<tr><td>Format Style:<td>${desc.formatStyle}
|
||||
<tr><td>Default Format:<td>${desc.defaultFormat!"<i>Determined at run-time</i>"}
|
||||
<tr><td>
|
||||
<tr><td>Id:<td>${desc.id}
|
||||
<tr><td>Description:<td><a href="${url.serviceContext}/description/${desc.id}">${desc.storePath}/${desc.descPath}</a>
|
||||
|
@@ -28,13 +28,14 @@ The following reference provides a list of all available Web Scripts organised b
|
||||
<#if desc.description??><#if desc.description?ends_with(".")>${desc.description}<#else>${desc.description}.</#if><#else></#if>
|
||||
|
||||
<#list desc.URIs as uri>
|
||||
[http://localhost:8080/${url.serviceContext}${uri.URI} ${desc.method} ${url.serviceContext}${uri.URI}] => ${uri.format}<#if uri.format = desc.defaultFormat> (default)</#if>
|
||||
[http://localhost:8080/${url.serviceContext}${uri} ${desc.method} ${url.serviceContext}${uri}]
|
||||
</#list>
|
||||
|
||||
Requirements:
|
||||
* Authentication: ${desc.requiredAuthentication}
|
||||
* Transaction: ${desc.requiredTransaction}
|
||||
* Format Style: ${desc.formatStyle}
|
||||
* Default Format: ${desc.defaultFormat!"<i>Determined at run-time</i>"}
|
||||
|
||||
Definition:
|
||||
* Id: ${desc.id}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<webscript>
|
||||
<shortname>Web Script Package Index</shortname>
|
||||
<description>Provide an index of Web Scripts for the specified Web Script package</description>
|
||||
<url format="html" template="/index/package/{package}" />
|
||||
<url>/index/package/{package}</url>
|
||||
</webscript>
|
@@ -41,7 +41,7 @@
|
||||
<span class="mainSubTitle">${desc.shortName}</span>
|
||||
<table>
|
||||
<#list desc.URIs as uri>
|
||||
<tr><td><a href="${url.serviceContext}${uri.URI}">${desc.method} ${url.serviceContext}${uri.URI}</a> => ${uri.format}<#if uri.format = desc.defaultFormat> (default)</#if>
|
||||
<tr><td><a href="${url.serviceContext}${uri}">${desc.method} ${url.serviceContext}${uri}</a>
|
||||
</#list>
|
||||
<tr><td>
|
||||
</table>
|
||||
@@ -50,6 +50,7 @@
|
||||
<tr><td>Authentication:<td>${desc.requiredAuthentication}
|
||||
<tr><td>Transaction:<td>${desc.requiredTransaction}
|
||||
<tr><td>Format Style:<td>${desc.formatStyle}
|
||||
<tr><td>Default Format:<td>${desc.defaultFormat!"<i>Determined at run-time</i>"}
|
||||
<tr><td>
|
||||
<tr><td>Id:<td>${desc.id}
|
||||
<tr><td>Description:<td><a href="${url.serviceContext}/description/${desc.id}">${desc.storePath}/${desc.descPath}</a>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<webscript>
|
||||
<shortname>Web Script URI Index</shortname>
|
||||
<description>Provide an index of Web Scripts for the specified Web Script URI</description>
|
||||
<url format="html" template="/index/uri/{uri}" />
|
||||
<url>/index/uri/{uri}</url>
|
||||
<format>argument</format>
|
||||
</webscript>
|
@@ -41,7 +41,7 @@
|
||||
<span class="mainSubTitle">${desc.shortName}</span>
|
||||
<table>
|
||||
<#list desc.URIs as uri>
|
||||
<tr><td><a href="${url.serviceContext}${uri.URI}">${desc.method} ${url.serviceContext}${uri.URI}</a> => ${uri.format}<#if uri.format = desc.defaultFormat> (default)</#if>
|
||||
<tr><td><a href="${url.serviceContext}${uri}">${desc.method} ${url.serviceContext}${uri}</a>
|
||||
</#list>
|
||||
<tr><td>
|
||||
</table>
|
||||
@@ -50,6 +50,7 @@
|
||||
<tr><td>Authentication:<td>${desc.requiredAuthentication}
|
||||
<tr><td>Transaction:<td>${desc.requiredTransaction}
|
||||
<tr><td>Format Style:<td>${desc.formatStyle}
|
||||
<tr><td>Default Format:<td>${desc.defaultFormat!"<i>Determined at run-time</i>"}
|
||||
<tr><td>
|
||||
<tr><td>Id:<td>${desc.id}
|
||||
<tr><td>Description:<td><a href="${url.serviceContext}/description/${desc.id}">${desc.storePath}/${desc.descPath}</a>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Document Actions (Office Add-In)</shortname>
|
||||
<description>Used by the Office Add-In to perform actions on managed documents</description>
|
||||
<url format="html" template="/office/docActions" />
|
||||
<url>/office/docActions</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Document Details (Office Add-In)</shortname>
|
||||
<description>Generate the Office Add-In Document Details page</description>
|
||||
<url format="html" template="/office/documentDetails?p={path?}" />
|
||||
<url>/office/documentDetails?p={path?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Get Users (Office Add-In)</shortname>
|
||||
<description>Used by the Office Add-In to query for users</description>
|
||||
<url format="html" template="/office/getUsers?s={searchTerm}" />
|
||||
<url>/office/getUsers?s={searchTerm}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>My Alfresco (Office Add-In)</shortname>
|
||||
<description>Generate the Office Add-In My Alfresco page</description>
|
||||
<url format="html" template="/office/myAlfresco?p={path?}" />
|
||||
<url>/office/myAlfresco?p={path?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>My Tasks (Office Add-In)</shortname>
|
||||
<description>Generate the Office Add-In My Tasks page</description>
|
||||
<url format="html" template="/office/myTasks?p={path}" />
|
||||
<url>/office/myTasks?p={path}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>My Tasks Detail (Office Add-In)</shortname>
|
||||
<description>Generate the Office Add-In Task Detail page</description>
|
||||
<url format="html" template="/office/myTasksDetail?t={taskId}" />
|
||||
<url>/office/myTasksDetail?t={taskId}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Navigation (Office Add-In)</shortname>
|
||||
<description>Generate the Office Add-In Navigation page</description>
|
||||
<url format="html" template="/office/navigation?p={path?}" />
|
||||
<url>/office/navigation?p={path?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Search (Office Add-In)</shortname>
|
||||
<description>Generate the Office Add-In Search page</description>
|
||||
<url format="html" template="/office/search?p={path?}" />
|
||||
<url>/office/search?p={path?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Search Results (Office Add-In)</shortname>
|
||||
<description>Generate the Office Add-In Search Results page</description>
|
||||
<url format="html" template="/office/searchResults?search={searchString?}&maxresults={maxresults?}" />
|
||||
<url>/office/searchResults?search={searchString?}&maxresults={maxresults?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Document List</shortname>
|
||||
<description>Generate the Document list portlet page</description>
|
||||
<url format="html" template="/doclist?f={filter?}&p={path?}&q={query?}"/>
|
||||
<url>/doclist?f={filter?}&p={path?}&q={query?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>My Spaces</shortname>
|
||||
<description>Generate the My Spaces portlet page</description>
|
||||
<url format="html" template="/myspaces?f={filter?}&p={path?}"/>
|
||||
<url>/myspaces?f={filter?}&p={path?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>My Spaces Panel</shortname>
|
||||
<description>Generate the inner panel for the My Spaces portlet page</description>
|
||||
<url format="html" template="/myspacespanel?f={filter}&p={path}&h={home}"/>
|
||||
<url>/myspacespanel?f={filter}&p={path}&h={home}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>My Tasks</shortname>
|
||||
<description>Generate the My Tasks portlet page</description>
|
||||
<url format="html" template="/mytasks?f={filter?}"/>
|
||||
<url>/mytasks?f={filter?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>My Tasks Panel</shortname>
|
||||
<description>Generate the Generate the inner panel for the My Tasks portlet page</description>
|
||||
<url format="html" template="/mytaskspanel?f={filter?}"/>
|
||||
<url>/mytaskspanel?f={filter?}</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>My Web Forms</shortname>
|
||||
<description>Generate the My Web Forms portlet page</description>
|
||||
<url format="html" template="/mywebforms"/>
|
||||
<url>/mywebforms</url>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,12 +1,12 @@
|
||||
<webscript>
|
||||
<shortname>Alfresco Keyword Search (OpenSearch Enabled)</shortname>
|
||||
<description>Execute Keyword Search against Alfresco Repository (Company Home and below)</description>
|
||||
<url format="html" template="/api/search/keyword.html?q={searchTerms}&p={startPage?}&c={count?}&l={language?}&guest={alf:guest?}"/>
|
||||
<url format="html" template="/search/keyword.html?q={searchTerms}&p={startPage?}&c={count?}&l={language?}&guest={alf:guest?}"/>
|
||||
<url format="atom" template="/api/search/keyword.atom?q={searchTerms}&p={startPage?}&c={count?}&l={language?}&guest={alf:guest?}"/>
|
||||
<url format="atom" template="/search/keyword.atom?q={searchTerms}&p={startPage?}&c={count?}&l={language?}&guest={alf:guest?}"/>
|
||||
<url format="rss" template="/api/search/keyword.rss?q={searchTerms}&p={startPage?}&c={count?}&l={language?}&guest={alf:guest?}"/>
|
||||
<url format="rss" template="/search/keyword.rss?q={searchTerms}&p={startPage?}&c={count?}&l={language?}&guest={alf:guest?}"/>
|
||||
<url format="portlet" template="/api/search/keyword.portlet?q={searchTerms}&p={startPage?}&c={count?}&l={language?}&guest={alf:guest?}"/>
|
||||
<url>/api/search/keyword.html?q={searchTerms}&p={startPage?}&c={count?}&l={language?}</url>
|
||||
<url>/search/keyword.html?q={searchTerms}&p={startPage?}&c={count?}&l={language?}</url>
|
||||
<url>/api/search/keyword.atom?q={searchTerms}&p={startPage?}&c={count?}&l={language?}</url>
|
||||
<url>/search/keyword.atom?q={searchTerms}&p={startPage?}&c={count?}&l={language?}</url>
|
||||
<url>/api/search/keyword.rss?q={searchTerms}&p={startPage?}&c={count?}&l={language?}</url>
|
||||
<url>/search/keyword.rss?q={searchTerms}&p={startPage?}&c={count?}&l={language?}</url>
|
||||
<url>/api/search/keyword.portlet?q={searchTerms}&p={startPage?}&c={count?}&l={language?}</url>
|
||||
<authentication>guest</authentication>
|
||||
</webscript>
|
@@ -1,7 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Keyword Search Description</shortname>
|
||||
<description>OpenSearch description document for Alfresco Repository keyword search</description>
|
||||
<url format="opensearchdescription" template="/api/search/keyword/description.xml" />
|
||||
<url format="opensearchdescription" template="/search/keyword/description.xml" />
|
||||
<format>argument</format>
|
||||
<url>/api/search/keyword/description.xml</url>
|
||||
<url>/search/keyword/description.xml</url>
|
||||
<format default="opensearchdescription">argument</format>
|
||||
</webscript>
|
@@ -1,7 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Login</shortname>
|
||||
<description>Establish a ticket</description>
|
||||
<url format="xml" template="/api/login?u={username}&pw={password?}"/>
|
||||
<url>/api/login?u={username}&pw={password?}</url>
|
||||
<format default="xml"/>
|
||||
<authentication>none</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Delete Login Ticket</shortname>
|
||||
<description>Delete Login Ticket</description>
|
||||
<url format="xml" template="/api/login/ticket/{ticket}"/>
|
||||
<url>/api/login/ticket/{ticket}</url>
|
||||
<format default="xml"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,7 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Get Login Ticket</shortname>
|
||||
<description>Get Login Ticket</description>
|
||||
<url format="xml" template="/api/login/ticket/{ticket}"/>
|
||||
<url>/api/login/ticket/{ticket}</url>
|
||||
<format default="xml"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -1,8 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Search Engines</shortname>
|
||||
<description>Lists "search engines" registered with this Alfresco Repository</description>
|
||||
<url format="html" template="/api/search/engines?type={type?}" />
|
||||
<url format="html" template="/search/engines?type={type?}" />
|
||||
<url format="atom" template="/api/search/engines.atom?type={type?}" />
|
||||
<url format="atom" template="/search/engines.atom?type={type?}" />
|
||||
<url>/api/search/engines?type={type?}</url>
|
||||
<url>/search/engines?type={type?}</url>
|
||||
<url>/api/search/engines.atom?type={type?}</url>
|
||||
<url>/search/engines.atom?type={type?}</url>
|
||||
</webscript>
|
@@ -1,6 +1,7 @@
|
||||
<webscript>
|
||||
<shortname>Proxied (OpenSearch) Search</shortname>
|
||||
<description>Search engine proxy for issuing a search against a remote search engine</description>
|
||||
<url template="/api/search/engine/{engine}/{format}"/>
|
||||
<url template="/search/engine/{engine}/{format}"/>
|
||||
<url>/api/search/engine/{engine}/{format}</url>
|
||||
<url>/search/engine/{engine}/{format}</url>
|
||||
<format default=""/>
|
||||
</webscript>
|
@@ -1,6 +1,6 @@
|
||||
<webscript>
|
||||
<shortname>Web Script Description</shortname>
|
||||
<description>Retrieve description document for identified Web Script</description>
|
||||
<url format="html" template="/description/{serviceId}" />
|
||||
<url>/description/{serviceId}</url>
|
||||
<format>argument</format>
|
||||
</webscript>
|
@@ -27,5 +27,4 @@
|
||||
${exception}
|
||||
${exception.stackTrace[0]}
|
||||
</#if>
|
||||
<tr><td><td>
|
||||
</#macro>
|
||||
|
@@ -43,7 +43,6 @@ import org.alfresco.util.AbstractLifecycleBean;
|
||||
import org.alfresco.web.scripts.WebScriptDescription.FormatStyle;
|
||||
import org.alfresco.web.scripts.WebScriptDescription.RequiredAuthentication;
|
||||
import org.alfresco.web.scripts.WebScriptDescription.RequiredTransaction;
|
||||
import org.alfresco.web.scripts.WebScriptDescription.URI;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -150,11 +149,20 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
* @see org.alfresco.web.scripts.WebScriptRegistry#reset()
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
try
|
||||
{
|
||||
getTemplateProcessor().resetCache();
|
||||
getScriptProcessor().resetCache();
|
||||
initWebScripts();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info("Registered " + webscriptsById.size() + " Web Scripts " + webscriptsByURL.size() + ", URLs (in " + (System.currentTimeMillis() - startTime) + "ms)");
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent)
|
||||
@@ -162,7 +170,7 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
initWebScripts();
|
||||
reset();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -178,7 +186,7 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
*
|
||||
* Note: Each invocation of this method resets the list of the services
|
||||
*/
|
||||
public void initWebScripts()
|
||||
private void initWebScripts()
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Initialising Web Scripts");
|
||||
@@ -250,17 +258,16 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Found Web Script " + id + " (desc: " + serviceDescPath + ", impl: " + serviceImplName + ", auth: " +
|
||||
serviceDesc.getRequiredAuthentication() + ", trx: " + serviceDesc.getRequiredTransaction() + ", format: " +
|
||||
serviceDesc.getFormatStyle() + ")");
|
||||
serviceDesc.getRequiredAuthentication() + ", trx: " + serviceDesc.getRequiredTransaction() + ", format style: " +
|
||||
serviceDesc.getFormatStyle() + ", default format: " + serviceDesc.getDefaultFormat() + ")");
|
||||
|
||||
// register service and its urls
|
||||
webscriptsById.put(id, serviceImpl);
|
||||
for (URI uri : serviceDesc.getURIs())
|
||||
for (String uriTemplate : serviceDesc.getURIs())
|
||||
{
|
||||
// establish static part of url template
|
||||
boolean wildcard = false;
|
||||
boolean extension = true;
|
||||
String uriTemplate = uri.getURI();
|
||||
int queryArgIdx = uriTemplate.indexOf('?');
|
||||
if (queryArgIdx != -1)
|
||||
{
|
||||
@@ -309,9 +316,6 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
registerURIs(serviceImpl);
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Registered " + webscriptsById.size() + " Web Scripts; " + webscriptsByURL.size() + " URLs");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,10 +351,10 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
private void registerURIs(WebScript script)
|
||||
{
|
||||
WebScriptDescription desc = script.getDescription();
|
||||
for (URI uri : desc.getURIs())
|
||||
for (String uri : desc.getURIs())
|
||||
{
|
||||
Path path = uriByPath.get("/");
|
||||
String[] parts = uri.getURI().split("/");
|
||||
String[] parts = uri.split("/");
|
||||
for (String part : parts)
|
||||
{
|
||||
if (part.indexOf("?") != -1)
|
||||
@@ -429,32 +433,25 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
{
|
||||
throw new WebScriptException("Expected at least one <url> element");
|
||||
}
|
||||
List<WebScriptDescription.URI> uris = new ArrayList<WebScriptDescription.URI>();
|
||||
List<String> uris = new ArrayList<String>();
|
||||
Iterator iterElements = urlElements.iterator();
|
||||
while(iterElements.hasNext())
|
||||
{
|
||||
// retrieve url element
|
||||
Element urlElement = (Element)iterElements.next();
|
||||
|
||||
// retrieve url mimetype
|
||||
String format = urlElement.attributeValue("format");
|
||||
if (format == null)
|
||||
{
|
||||
// default to unspecified format
|
||||
format = "";
|
||||
}
|
||||
|
||||
// retrieve url template
|
||||
String template = urlElement.attributeValue("template");
|
||||
String template = urlElement.getTextTrim();
|
||||
if (template == null || template.length() == 0)
|
||||
{
|
||||
throw new WebScriptException("Expected template attribute on <url> element");
|
||||
// NOTE: for backwards compatibility only
|
||||
template = urlElement.attributeValue("template");
|
||||
if (template == null || template.length() == 0)
|
||||
{
|
||||
throw new WebScriptException("Expected <url> element value");
|
||||
}
|
||||
|
||||
WebScriptDescriptionImpl.URIImpl uriImpl = new WebScriptDescriptionImpl.URIImpl();
|
||||
uriImpl.setFormat(format);
|
||||
uriImpl.setUri(template);
|
||||
uris.add(uriImpl);
|
||||
}
|
||||
uris.add(template);
|
||||
}
|
||||
|
||||
// retrieve authentication
|
||||
@@ -492,11 +489,18 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
}
|
||||
|
||||
// retrieve format
|
||||
String defaultFormat = uris.get(0).getFormat();
|
||||
String defaultFormat = "html";
|
||||
FormatStyle formatStyle = FormatStyle.any;
|
||||
Element formatElement = rootElement.element("format");
|
||||
if (formatElement != null)
|
||||
{
|
||||
// establish if default is set explicitly
|
||||
String attrDefaultValue = formatElement.attributeValue("default");
|
||||
if (attrDefaultValue != null)
|
||||
{
|
||||
defaultFormat = (attrDefaultValue.length() == 0) ? null : attrDefaultValue;
|
||||
}
|
||||
// establish format declaration style
|
||||
String formatStyleStr = formatElement.getTextTrim();
|
||||
if (formatStyleStr != null && formatStyleStr.length() > 0)
|
||||
{
|
||||
@@ -506,11 +510,6 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
throw new WebScriptException("Format Style '" + formatStyle + "' is not a valid value");
|
||||
}
|
||||
}
|
||||
String defaultFormatStr = formatElement.attributeValue("default");
|
||||
if (defaultFormatStr != null && defaultFormatStr.length() > 0)
|
||||
{
|
||||
defaultFormat = defaultFormatStr;
|
||||
}
|
||||
}
|
||||
|
||||
// construct service description
|
||||
@@ -524,7 +523,7 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
||||
serviceDesc.setRequiredAuthentication(reqAuth);
|
||||
serviceDesc.setRequiredTransaction(reqTrx);
|
||||
serviceDesc.setMethod(method);
|
||||
serviceDesc.setUris(uris.toArray(new WebScriptDescription.URI[uris.size()]));
|
||||
serviceDesc.setUris(uris.toArray(new String[uris.size()]));
|
||||
serviceDesc.setDefaultFormat(defaultFormat);
|
||||
serviceDesc.setFormatStyle(formatStyle);
|
||||
return serviceDesc;
|
||||
|
@@ -140,7 +140,7 @@ public interface WebScriptDescription
|
||||
*
|
||||
* @return array of URIs in order specified in service description document
|
||||
*/
|
||||
public URI[] getURIs();
|
||||
public String[] getURIs();
|
||||
|
||||
/**
|
||||
* Gets the style of Format discriminator supported by this web script
|
||||
@@ -149,45 +149,14 @@ public interface WebScriptDescription
|
||||
*/
|
||||
public FormatStyle getFormatStyle();
|
||||
|
||||
/**
|
||||
* Gets a URI by format
|
||||
*
|
||||
* @param format the format
|
||||
* @return the URI (or null, if no URI registered for the format)
|
||||
*/
|
||||
public URI getURI(String format);
|
||||
|
||||
/**
|
||||
* Gets the default response format
|
||||
*
|
||||
* Note: the default response format is the first listed in the service
|
||||
* description document
|
||||
*
|
||||
* @return default response format
|
||||
* @return default response format (or null, if format not known until run-time)
|
||||
*/
|
||||
public String getDefaultFormat();
|
||||
|
||||
|
||||
/**
|
||||
* Web Script URL
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public interface URI
|
||||
{
|
||||
/**
|
||||
* Gets the URI response format
|
||||
*
|
||||
* @return format
|
||||
*/
|
||||
public String getFormat();
|
||||
|
||||
/**
|
||||
* Gets the URI
|
||||
*
|
||||
* @return uri
|
||||
*/
|
||||
public String getURI();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,8 +26,6 @@ package org.alfresco.web.scripts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,9 +45,8 @@ public class WebScriptDescriptionImpl implements WebScriptDescription
|
||||
private RequiredTransaction requiredTransaction;
|
||||
private FormatStyle formatStyle;
|
||||
private String httpMethod;
|
||||
private URI[] uris;
|
||||
private String[] uris;
|
||||
private String defaultFormat;
|
||||
private Map<String, URI> uriByFormat;
|
||||
|
||||
|
||||
/**
|
||||
@@ -246,32 +243,19 @@ public class WebScriptDescriptionImpl implements WebScriptDescription
|
||||
*
|
||||
* @param uris
|
||||
*/
|
||||
public void setUris(URI[] uris)
|
||||
public void setUris(String[] uris)
|
||||
{
|
||||
this.uriByFormat = new HashMap<String, URI>(uris.length);
|
||||
for (URI uri : uris)
|
||||
{
|
||||
this.uriByFormat.put(uri.getFormat(), uri);
|
||||
}
|
||||
this.uris = uris;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptDescription#getURIs()
|
||||
*/
|
||||
public URI[] getURIs()
|
||||
public String[] getURIs()
|
||||
{
|
||||
return this.uris;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptDescription#getURI(java.lang.String)
|
||||
*/
|
||||
public URI getURI(String format)
|
||||
{
|
||||
return this.uriByFormat.get(format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default response format
|
||||
*
|
||||
@@ -290,52 +274,4 @@ public class WebScriptDescriptionImpl implements WebScriptDescription
|
||||
return this.defaultFormat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Web Script URL Implementation
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public static class URIImpl implements WebScriptDescription.URI
|
||||
{
|
||||
private String format;
|
||||
private String uri;
|
||||
|
||||
/**
|
||||
* Sets the URI response format
|
||||
*
|
||||
* @param format
|
||||
*/
|
||||
public void setFormat(String format)
|
||||
{
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptDescription.URI#getFormat()
|
||||
*/
|
||||
public String getFormat()
|
||||
{
|
||||
return this.format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URI
|
||||
*
|
||||
* @param uri
|
||||
*/
|
||||
public void setUri(String uri)
|
||||
{
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.web.scripts.WebScriptDescription.URI#getURI()
|
||||
*/
|
||||
public String getURI()
|
||||
{
|
||||
return this.uri;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user