diff --git a/config/alfresco/application-context-highlevel.xml b/config/alfresco/application-context-highlevel.xml
index d684be07dd..3fe7e62a24 100644
--- a/config/alfresco/application-context-highlevel.xml
+++ b/config/alfresco/application-context-highlevel.xml
@@ -33,5 +33,6 @@
+
diff --git a/config/alfresco/script-services-context.xml b/config/alfresco/script-services-context.xml
index bf7dad9938..c6e0a4667a 100644
--- a/config/alfresco/script-services-context.xml
+++ b/config/alfresco/script-services-context.xml
@@ -3,8 +3,8 @@
-
-
+
+
javascript
@@ -16,7 +16,7 @@
-
+
javascript
diff --git a/config/alfresco/slingshot-context.xml b/config/alfresco/slingshot-context.xml
new file mode 100644
index 0000000000..e52a2d9a73
--- /dev/null
+++ b/config/alfresco/slingshot-context.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+ classpath*:alfresco/module/org.alfresco.module.vti/context/vti.properties
+
+ classpath*:alfresco/extension/custom-vti.properties
+
+
+
+
+
+ 0
+ null
+
+
+
+
+
+
+ ${vti.server.external.port}
+
+
+ ${vti.server.external.host}
+
+
+
+
+
+
+
+
+ slingshotDocLib
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/jscript/ApplicationScriptUtils.java b/source/java/org/alfresco/repo/jscript/ApplicationScriptUtils.java
index bed989d0dc..9ac39d14fa 100644
--- a/source/java/org/alfresco/repo/jscript/ApplicationScriptUtils.java
+++ b/source/java/org/alfresco/repo/jscript/ApplicationScriptUtils.java
@@ -19,7 +19,7 @@
package org.alfresco.repo.jscript;
import org.alfresco.model.ContentModel;
-import org.alfresco.repo.jscript.app.JSONPropertyDecorator;
+import org.alfresco.repo.jscript.app.PropertyDecorator;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -237,7 +237,7 @@ public final class ApplicationScriptUtils extends BaseScopableProcessorExtension
// Has a decorator has been registered for this property?
if (this.decoratedProperties.containsKey(shortQName))
{
- json.put(key, ((JSONPropertyDecorator) this.decoratedProperties.get(shortQName)).decorate(nodeRef, shortQName, value));
+ json.put(key, ((PropertyDecorator) this.decoratedProperties.get(shortQName)).decorate(nodeRef, shortQName, value));
}
else
{
diff --git a/source/java/org/alfresco/repo/jscript/SlingshotDocLibCustomResponse.java b/source/java/org/alfresco/repo/jscript/SlingshotDocLibCustomResponse.java
new file mode 100644
index 0000000000..59ba980b34
--- /dev/null
+++ b/source/java/org/alfresco/repo/jscript/SlingshotDocLibCustomResponse.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.jscript;
+
+import org.alfresco.repo.jscript.app.CustomResponse;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Populates DocLib webscript response with custom metadata output
+ *
+ * @author: mikeh
+ */
+public final class SlingshotDocLibCustomResponse extends BaseScopableProcessorExtension
+{
+ private Map customResponses;
+
+ /**
+ * Set the custom response beans
+ *
+ * @param customResponses
+ */
+ public void setCustomResponses(Map customResponses)
+ {
+ this.customResponses = customResponses;
+ }
+
+ /**
+ * Returns a JSON string to be added to the DocLib webscript response.
+ *
+ * @return The JSON string
+ */
+ public String getJSON()
+ {
+ return this.getJSONObj().toString();
+ }
+
+ /**
+ * Returns a JSON object to be added to the DocLib webscript response.
+ *
+ * @return The JSON object
+ */
+ protected Object getJSONObj()
+ {
+ JSONObject json = new JSONObject();
+
+
+ for (Map.Entry entry : this.customResponses.entrySet())
+ {
+ try
+ {
+ Serializable response = ((CustomResponse) entry.getValue()).populate();
+ json.put(entry.getKey(), response == null ? JSONObject.NULL: response);
+ }
+ catch (JSONException error)
+ {
+ error.printStackTrace();
+ }
+ }
+
+ return json;
+ }
+}
diff --git a/source/java/org/alfresco/repo/jscript/app/CategoryPropertyDecorator.java b/source/java/org/alfresco/repo/jscript/app/CategoryPropertyDecorator.java
index d0ff2b4325..5abce11f0b 100644
--- a/source/java/org/alfresco/repo/jscript/app/CategoryPropertyDecorator.java
+++ b/source/java/org/alfresco/repo/jscript/app/CategoryPropertyDecorator.java
@@ -37,7 +37,7 @@ import java.util.Map;
*
* @author Mike Hatfield
*/
-public class CategoryPropertyDecorator implements JSONPropertyDecorator
+public class CategoryPropertyDecorator implements PropertyDecorator
{
private static Log logger = LogFactory.getLog(CategoryPropertyDecorator.class);
diff --git a/source/java/org/alfresco/repo/jscript/app/CustomResponse.java b/source/java/org/alfresco/repo/jscript/app/CustomResponse.java
new file mode 100644
index 0000000000..3317530991
--- /dev/null
+++ b/source/java/org/alfresco/repo/jscript/app/CustomResponse.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+
+package org.alfresco.repo.jscript.app;
+
+import java.io.Serializable;
+
+/**
+ * Interface for custom properties used by SlingshotDocLibCustomResponse
+ *
+ * @author: mikeh
+ */
+public interface CustomResponse
+{
+ /**
+ * Populates the DocLib webscript response with custom metadata
+ */
+ Serializable populate();
+}
diff --git a/source/java/org/alfresco/repo/jscript/app/JSONPropertyDecorator.java b/source/java/org/alfresco/repo/jscript/app/PropertyDecorator.java
similarity index 96%
rename from source/java/org/alfresco/repo/jscript/app/JSONPropertyDecorator.java
rename to source/java/org/alfresco/repo/jscript/app/PropertyDecorator.java
index 5b7aa74bc9..60a33542c5 100644
--- a/source/java/org/alfresco/repo/jscript/app/JSONPropertyDecorator.java
+++ b/source/java/org/alfresco/repo/jscript/app/PropertyDecorator.java
@@ -26,7 +26,7 @@ import java.io.Serializable;
*
* @author Mike Hatfield
*/
-public interface JSONPropertyDecorator
+public interface PropertyDecorator
{
Serializable decorate(NodeRef nodeRef, String propertyName, Serializable value);
}
diff --git a/source/java/org/alfresco/repo/jscript/app/TagPropertyDecorator.java b/source/java/org/alfresco/repo/jscript/app/TagPropertyDecorator.java
index a2464aaa46..c2b12b69fb 100644
--- a/source/java/org/alfresco/repo/jscript/app/TagPropertyDecorator.java
+++ b/source/java/org/alfresco/repo/jscript/app/TagPropertyDecorator.java
@@ -36,7 +36,7 @@ import java.util.Map;
*
* @author Mike Hatfield
*/
-public class TagPropertyDecorator implements JSONPropertyDecorator
+public class TagPropertyDecorator implements PropertyDecorator
{
private static Log logger = LogFactory.getLog(TagPropertyDecorator.class);
diff --git a/source/java/org/alfresco/repo/jscript/app/UsernamePropertyDecorator.java b/source/java/org/alfresco/repo/jscript/app/UsernamePropertyDecorator.java
index d4042f3194..e13b3c3852 100644
--- a/source/java/org/alfresco/repo/jscript/app/UsernamePropertyDecorator.java
+++ b/source/java/org/alfresco/repo/jscript/app/UsernamePropertyDecorator.java
@@ -34,7 +34,7 @@ import java.util.Map;
*
* @author Mike Hatfield
*/
-public class UsernamePropertyDecorator implements JSONPropertyDecorator
+public class UsernamePropertyDecorator implements PropertyDecorator
{
private ServiceRegistry services;
private NodeService nodeService = null;
diff --git a/source/java/org/alfresco/repo/jscript/app/VtiServerCustomResponse.java b/source/java/org/alfresco/repo/jscript/app/VtiServerCustomResponse.java
new file mode 100644
index 0000000000..bb1cd3aaf9
--- /dev/null
+++ b/source/java/org/alfresco/repo/jscript/app/VtiServerCustomResponse.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2005-2011 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.jscript.app;
+
+import org.alfresco.repo.admin.SysAdminParams;
+import org.alfresco.repo.jscript.ScriptUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ibatis.migration.commands.StatusCommand;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+
+import java.io.Serializable;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Return current state of VTI (SharePoint) Server module
+ *
+ * @author: mikeh
+ */
+public class VtiServerCustomResponse implements CustomResponse
+{
+ private static Log logger = LogFactory.getLog(VtiServerCustomResponse.class);
+
+ private static final String VTI_MODULE = "org.alfresco.module.vti";
+
+ private int vtiServerPort = 0;
+ private String vtiServerHost;
+ private SysAdminParams sysAdminParams;
+ private ScriptUtils scriptUtils;
+
+ /*
+ * Set ScriptUtils
+ *
+ * @param scriptUtils
+ */
+ public void setScriptUtils(ScriptUtils scriptUtils) throws BeansException
+ {
+ this.scriptUtils = scriptUtils;
+ }
+
+ /**
+ * Setter for vtiServer Port
+ *
+ * @param vtiServerPort
+ */
+ public void setPort(int vtiServerPort)
+ {
+ this.vtiServerPort = vtiServerPort;
+ }
+
+ /**
+ * Setter for vtiServer Host
+ *
+ * @param vtiServerHost
+ */
+ public void setHost(String vtiServerHost)
+ {
+ this.vtiServerHost = vtiServerHost;
+ }
+
+ /**
+ * Setter for sysAdminParams
+ *
+ * @param sysAdminParams
+ */
+ public void setSysAdminParams(SysAdminParams sysAdminParams)
+ {
+ this.sysAdminParams = sysAdminParams;
+ }
+
+ /**
+ * Populates the DocLib webscript response with custom metadata
+ *
+ * @return JSONObject or null
+ */
+ public Serializable populate()
+ {
+ try
+ {
+ // Check module is installed
+ if (!this.scriptUtils.moduleInstalled(VTI_MODULE))
+ {
+ return null;
+ }
+
+ Map jsonObj = new LinkedHashMap(4);
+ if (this.vtiServerPort != 0)
+ {
+ jsonObj.put("port", this.vtiServerPort);
+ }
+ if (this.vtiServerHost != null)
+ {
+ jsonObj.put("host", this.sysAdminParams.subsituteHost(this.vtiServerHost));
+ }
+ return (Serializable)jsonObj;
+ }
+ catch (Exception e)
+ {
+ logger.warn("Could not add custom Vti Server response to DocLib webscript");
+ }
+ return null;
+ }
+}