diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/loginticket.delete.xml.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/loginticket.delete.xml.ftl
deleted file mode 100644
index d311e170fd..0000000000
--- a/config/alfresco/templates/webscripts/org/alfresco/repository/loginticket.delete.xml.ftl
+++ /dev/null
@@ -1,2 +0,0 @@
-
-${ticket}
diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/loginticket.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/loginticket.get.desc.xml
index 84384ebd12..62b5dcffd4 100644
--- a/config/alfresco/templates/webscripts/org/alfresco/repository/loginticket.get.desc.xml
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/loginticket.get.desc.xml
@@ -1,6 +1,6 @@
- Login Ticket
- Login Ticket
+ Get Login Ticket
+ Get Login Ticket
user
required
diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml
index c63f637954..ac61906acb 100644
--- a/config/alfresco/web-scripts-application-context.xml
+++ b/config/alfresco/web-scripts-application-context.xml
@@ -2,9 +2,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ workspace://SpacesStore
+ /${spaces.company_home.childname}/${spaces.dictionary.childname}/cm:extensionwebscripts
+
+
+
+ true
+ workspace://SpacesStore
+ /${spaces.company_home.childname}/${spaces.dictionary.childname}/cm:webscripts
+
+
+
+ alfresco/extension/templates/webscripts
+
+
+
+ true
+ alfresco/templates/webscripts
+
+
+
+
+
+
+
-
+
@@ -15,11 +55,6 @@
-
-
-
-
-
@@ -30,14 +65,9 @@
/${spaces.company_home.childname}
-
-
-
-
-
-
-
+
+
@@ -45,33 +75,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- workspace://SpacesStore
- /${spaces.company_home.childname}/${spaces.dictionary.childname}/cm:webscripts
-
-
-
- alfresco/templates/webscripts
-
-
-
+
@@ -93,11 +99,10 @@
-
-
+
@@ -138,7 +143,7 @@
-
+
@@ -159,7 +164,7 @@
-
+
@@ -174,7 +179,7 @@
-
+
diff --git a/source/java/org/alfresco/web/scripts/ClassPathStore.java b/source/java/org/alfresco/web/scripts/ClassPathStore.java
index 9ce6276b4f..d1a4da5ad9 100644
--- a/source/java/org/alfresco/web/scripts/ClassPathStore.java
+++ b/source/java/org/alfresco/web/scripts/ClassPathStore.java
@@ -53,10 +53,24 @@ import freemarker.cache.TemplateLoader;
public class ClassPathStore implements WebScriptStore, InitializingBean
{
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+ protected boolean mustExist = false;
protected String classPath;
protected File fileDir;
+ /**
+ * Sets whether the class path must exist
+ *
+ * If it must exist, but it doesn't exist, an exception is thrown
+ * on initialisation of the store
+ *
+ * @param mustExist
+ */
+ public void setMustExist(boolean mustExist)
+ {
+ this.mustExist = mustExist;
+ }
+
/**
* Sets the class path
*
@@ -74,7 +88,22 @@ public class ClassPathStore implements WebScriptStore, InitializingBean
throws Exception
{
ClassPathResource resource = new ClassPathResource(classPath);
- fileDir = resource.getFile();
+ if (resource.exists())
+ {
+ fileDir = resource.getFile();
+ }
+ else if (mustExist)
+ {
+ throw new WebScriptException("Web Script Store classpath:" + classPath + " must exist; it was not found");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.web.scripts.WebScriptStore#exists()
+ */
+ public boolean exists()
+ {
+ return (fileDir != null);
}
/* (non-Javadoc)
diff --git a/source/java/org/alfresco/web/scripts/RepoStore.java b/source/java/org/alfresco/web/scripts/RepoStore.java
index 90a2112120..094e0ffdc3 100644
--- a/source/java/org/alfresco/web/scripts/RepoStore.java
+++ b/source/java/org/alfresco/web/scripts/RepoStore.java
@@ -63,6 +63,7 @@ import freemarker.cache.TemplateLoader;
public class RepoStore implements WebScriptStore, ApplicationContextAware, ApplicationListener
{
private ProcessorLifecycle lifecycle = new ProcessorLifecycle();
+ protected boolean mustExist = false;
protected StoreRef repoStore;
protected String repoPath;
protected NodeRef baseNodeRef;
@@ -116,6 +117,16 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli
this.namespaceService = namespaceService;
}
+ /**
+ * Sets whether the repo store must exist
+ *
+ * @param mustExist
+ */
+ public void setMustExist(boolean mustExist)
+ {
+ this.mustExist = mustExist;
+ }
+
/**
* Sets the repo store
*/
@@ -182,23 +193,30 @@ public class RepoStore implements WebScriptStore, ApplicationContextAware, Appli
{
String query = "PATH:\"" + repoPath + "\"";
ResultSet resultSet = searchService.query(repoStore, SearchService.LANGUAGE_LUCENE, query);
- if (resultSet.length() == 0)
+ if (resultSet.length() == 1)
{
- throw new WebScriptException("Unable to locate repository path " + repoStore.toString() + repoPath);
+ baseNodeRef = resultSet.getNodeRef(0);
+ baseDir = getPath(baseNodeRef);
}
- if (resultSet.length() > 1)
+ else if (mustExist)
{
- throw new WebScriptException("Multiple repository paths found for " + repoStore.toString() + repoPath);
+ throw new WebScriptException("Web Script Store " + repoStore.toString() + repoPath + " must exist; it was not found");
}
- baseNodeRef = resultSet.getNodeRef(0);
- baseDir = getPath(baseNodeRef);
return null;
}
});
}
}, AuthenticationUtil.getSystemUserName());
}
-
+
+ /* (non-Javadoc)
+ * @see org.alfresco.web.scripts.WebScriptStore#exists()
+ */
+ public boolean exists()
+ {
+ return (baseNodeRef != null);
+ }
+
/* (non-Javadoc)
* @see org.alfresco.web.scripts.WebScriptStore#getBasePath()
*/
diff --git a/source/java/org/alfresco/web/scripts/WebScriptRuntime.java b/source/java/org/alfresco/web/scripts/WebScriptRuntime.java
index ad8818bb58..b4768020ad 100644
--- a/source/java/org/alfresco/web/scripts/WebScriptRuntime.java
+++ b/source/java/org/alfresco/web/scripts/WebScriptRuntime.java
@@ -217,7 +217,7 @@ public abstract class WebScriptRuntime
templatePath = "/status.ftl";
if (!registry.getTemplateProcessor().hasTemplate(templatePath))
{
- throw new WebScriptException("Failed to find status template " + status + " (format: " + WebScriptResponse.HTML_FORMAT + ")");
+ throw new WebScriptException("Failed to find status template " + templatePath + " (format: " + WebScriptResponse.HTML_FORMAT + ")");
}
}
diff --git a/source/java/org/alfresco/web/scripts/WebScriptStorage.java b/source/java/org/alfresco/web/scripts/WebScriptStorage.java
index 930391c89d..40afcabd79 100644
--- a/source/java/org/alfresco/web/scripts/WebScriptStorage.java
+++ b/source/java/org/alfresco/web/scripts/WebScriptStorage.java
@@ -97,7 +97,16 @@ public class WebScriptStorage implements ApplicationContextAware, ApplicationLis
@SuppressWarnings("unchecked")
public Collection getStores()
{
- return applicationContext.getBeansOfType(WebScriptStore.class, false, false).values();
+ Collection allstores = applicationContext.getBeansOfType(WebScriptStore.class, false, false).values();
+ Collection stores = new ArrayList();
+ for (WebScriptStore store : allstores)
+ {
+ if (store.exists())
+ {
+ stores.add(store);
+ }
+ }
+ return stores;
}
/**
diff --git a/source/java/org/alfresco/web/scripts/WebScriptStore.java b/source/java/org/alfresco/web/scripts/WebScriptStore.java
index ee2f24cbe0..09aa3a38f3 100644
--- a/source/java/org/alfresco/web/scripts/WebScriptStore.java
+++ b/source/java/org/alfresco/web/scripts/WebScriptStore.java
@@ -37,7 +37,13 @@ import freemarker.cache.TemplateLoader;
*/
public interface WebScriptStore
{
-
+ /**
+ * Determines whether the store actually exists
+ *
+ * @return true => it does exist
+ */
+ public boolean exists();
+
/**
* Gets the base path of the store
*
diff --git a/source/java/org/alfresco/web/scripts/bean/LoginTicketDelete.java b/source/java/org/alfresco/web/scripts/bean/LoginTicketDelete.java
index f65b77093c..9639c8a072 100644
--- a/source/java/org/alfresco/web/scripts/bean/LoginTicketDelete.java
+++ b/source/java/org/alfresco/web/scripts/bean/LoginTicketDelete.java
@@ -83,7 +83,7 @@ public class LoginTicketDelete extends DeclarativeWebScript
// construct model for ticket
Map model = new HashMap(7, 1.0f);
model.put("ticket", ticket);
-
+
try
{
String ticketUser = ticketComponent.validateTicket(ticket);
@@ -91,7 +91,6 @@ public class LoginTicketDelete extends DeclarativeWebScript
// do not go any further if tickets are different
if (!AuthenticationUtil.getCurrentUserName().equals(ticketUser))
{
- status.setRedirect(true);
status.setCode(HttpServletResponse.SC_NOT_FOUND);
status.setMessage("Ticket not found");
}
@@ -99,15 +98,16 @@ public class LoginTicketDelete extends DeclarativeWebScript
{
// delete the ticket
authenticationService.invalidateTicket(ticket);
+ status.setMessage("Deleted Ticket " + ticket);
}
}
catch(AuthenticationException e)
{
- status.setRedirect(true);
status.setCode(HttpServletResponse.SC_NOT_FOUND);
status.setMessage("Ticket not found");
}
-
+
+ status.setRedirect(true);
return model;
}