mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Fix AR-1536: Customer raised issue where broken webscript caused repo to fail at startup
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6086 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -207,6 +207,8 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
|||||||
|
|
||||||
String[] serviceDescPaths = apiStore.getDescriptionDocumentPaths();
|
String[] serviceDescPaths = apiStore.getDescriptionDocumentPaths();
|
||||||
for (String serviceDescPath : serviceDescPaths)
|
for (String serviceDescPath : serviceDescPaths)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// build service description
|
// build service description
|
||||||
WebScriptDescription serviceDesc = null;
|
WebScriptDescription serviceDesc = null;
|
||||||
@@ -315,6 +317,26 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
|||||||
registerPackage(serviceImpl);
|
registerPackage(serviceImpl);
|
||||||
registerURIs(serviceImpl);
|
registerURIs(serviceImpl);
|
||||||
}
|
}
|
||||||
|
catch(WebScriptException e)
|
||||||
|
{
|
||||||
|
if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
Throwable c = e;
|
||||||
|
String cause = c.getMessage();
|
||||||
|
while (c.getCause() != null && !c.getCause().equals(c))
|
||||||
|
{
|
||||||
|
c = c.getCause();
|
||||||
|
cause += " ; " + c.getMessage();
|
||||||
|
}
|
||||||
|
String msg = "Unable to register script " + apiStore.getBasePath() + "/" + serviceDescPath + " due to error: " + cause;
|
||||||
|
logger.warn(msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,13 +407,6 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
|||||||
SAXReader reader = new SAXReader();
|
SAXReader reader = new SAXReader();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Document document = reader.read(serviceDoc);
|
|
||||||
Element rootElement = document.getRootElement();
|
|
||||||
if (!rootElement.getName().equals("webscript"))
|
|
||||||
{
|
|
||||||
throw new WebScriptException("Expected <webscript> root element - found <" + rootElement.getName() + ">");
|
|
||||||
}
|
|
||||||
|
|
||||||
// retrieve script path
|
// retrieve script path
|
||||||
int iPathIdx = serviceDescPath.lastIndexOf('/');
|
int iPathIdx = serviceDescPath.lastIndexOf('/');
|
||||||
String scriptPath = serviceDescPath.substring(0, iPathIdx == -1 ? 0 : iPathIdx);
|
String scriptPath = serviceDescPath.substring(0, iPathIdx == -1 ? 0 : iPathIdx);
|
||||||
@@ -401,11 +416,19 @@ public class DeclarativeWebScriptRegistry extends AbstractLifecycleBean
|
|||||||
|
|
||||||
// retrieve http method
|
// retrieve http method
|
||||||
int methodIdx = id.lastIndexOf('.');
|
int methodIdx = id.lastIndexOf('.');
|
||||||
if (methodIdx == id.length() - 1)
|
if (methodIdx == -1 || (methodIdx == id.length() - 1))
|
||||||
{
|
{
|
||||||
throw new WebScriptException("Unable to establish HTTP Method from web script description: naming convention must be <name>.<method>.desc.xml");
|
throw new WebScriptException("Unable to establish HTTP Method from web script description: naming convention must be <name>.<method>.desc.xml");
|
||||||
}
|
}
|
||||||
String method = id.substring(id.lastIndexOf('.') + 1).toUpperCase();
|
String method = id.substring(methodIdx + 1).toUpperCase();
|
||||||
|
|
||||||
|
// parse description document
|
||||||
|
Document document = reader.read(serviceDoc);
|
||||||
|
Element rootElement = document.getRootElement();
|
||||||
|
if (!rootElement.getName().equals("webscript"))
|
||||||
|
{
|
||||||
|
throw new WebScriptException("Expected <webscript> root element - found <" + rootElement.getName() + ">");
|
||||||
|
}
|
||||||
|
|
||||||
// retrieve short name
|
// retrieve short name
|
||||||
Element shortNameElement = rootElement.element("shortname");
|
Element shortNameElement = rootElement.element("shortname");
|
||||||
|
Reference in New Issue
Block a user