04-01-2011 05:54 AM
package org.alfresco.module.demoscripts;
import java.io.IOException;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.json.JSONException;
import org.json.JSONObject;
public class SimpleWebScript extends AbstractWebScript
{
public void execute(WebScriptRequest req, WebScriptResponse res)
throws IOException
{
try
{
// build a json object
JSONObject obj = new JSONObject();
// put some data on it
obj.put("field1", "data1");
// build a JSON string and send it back
String jsonString = obj.toString();
res.getWriter().write(jsonString);
}
catch(JSONException e)
{
throw new WebScriptException("Unable to serialize JSON");
}
}
}
<webscript>
<shortname>The World's Simplest Webscript</shortname>
<description>Hands back a little bit of JSON</description>
<url>/demo/simple</url>
<authentication>none</authentication>
<format default="">argument</format>
</webscript>
<bean id="webscript.demo.simple.get"
class="alfresco.lib"
parent="webscript">
</bean>
Note that the bean id is made up of:
* prefix = webscript (must always start with this value)
* packageId = org.alfresco.sample
* serviceId = helloworld
* httpMethod = get
From this we can determine that the descriptor for this Web Script is called helloworld.get.desc.xml and is located in the directory org/alfresco/sample (either in the repository or in the classpath, as described in Deciding Where to place Web Script Implementation).
These files need to be stored in a folder somewhere. They can live in either the Alfresco Repository or the Java ClassPath. The following folders are listed in the sequence in which Alfresco searches for Web Script implementation files:
1. repository folder: /Company Home/Data Dictionary/Web Scripts Extensions
2. repository folder: /Company Home/Data Dictionary/Web Scripts
3. class path folder: /alfresco/extension/templates/webscripts
4. class path folder: /alfresco/templates/webscripts
04-01-2011 06:06 AM
<bean id="webscript.demo.simple.simple.get"
class="org.alfresco.module.demoscripts.SimpleWebScript"
parent="webscript">
</bean>
Hope this helps :wink:
04-01-2011 07:02 AM
An error has occured in the Share component: /share/service/components/dashlets/user-calendar.
It responded with a status of 500 - Internal Error.
Locations of the files
On Alfresco Share Standalone (3.3 or greater)
.class files in <Alfresco>/tomcat/webapps/alfresco/WEB-INF/classes/<class folder structure>
04-01-2011 07:13 AM
04-01-2011 08:23 AM
04-01-2011 11:17 AM
04-04-2011 02:35 AM
<bean id="webscript.demo.simple.get"
class="alfresco.lib.simpleWebScript"
parent="webscript">
</bean
>04-04-2011 04:03 AM
/tomcat/shared/classes/alfresco/extension/templates/webscripts/demo
An I think that it should work now :wink:
04-04-2011 07:18 AM
.jar file in <tomcat>/webapps/share/WEB-INF/lib or .class files in <Alfresco>/tomcat/webapps/alfresco/WEB-INF/classes/<class folder structure>
web-scripts-application-context.xml - <tomcat>/webapps/share/WEB-INF/classes/org/springframework/extensions/webscripts
simple.get.desc.xml - <tomcat>/webapps/share/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/demo
04-06-2011 04:34 AM
500 Description: An error inside the HTTP server which prevented it from fulfilling the request.
Message: java.lang.NullPointerException
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.