Alfresco Share - Develop a webscript in JAVA
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2011 05:28 AM
Hi everybody,
I would try to create a new webscript in JAVA not in Javascript only in Alfreso Share.
I try to refer to the link below :
http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples
and especially about the locations files in Share :
I realize that when I connect to the URL http://localhost:8080/share/service/index , I can't find again a new webscript in the list.
Could someone give me more informations ?
Thanks so much for your help.
I would try to create a new webscript in JAVA not in Javascript only in Alfreso Share.
I try to refer to the link below :
http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples
and especially about the locations files in Share :
.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
I realize that when I connect to the URL http://localhost:8080/share/service/index , I can't find again a new webscript in the list.
Could someone give me more informations ?
Thanks so much for your help.
Labels:
- Labels:
-
Archive
25 REPLIES 25
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2011 11:01 AM
Hi,
Thanks for the reply. Yes I followed the instructions from this wiki page before I asked for help. I try example on Alfresco and works for me, but when I try same on Alfresco Share there is no new web scripts when I refresh web scripts list.
I add this:
1. New "web-scripts-application-context.xml" file in tomcat/webapps/share/WEB-INF/classes/org/springframework/extensions/webscripts/.
2. "simple.get.desc.xml" file in tomcat/webapps/share/WEB-INF/classes/org/springframework/extensions/webscripts/.
3. "simple.get.html.ftl" file at same location.
4. "SimpleWebScript.jar" file in tomcat/webapps/share/WEB-INF/lib/.
Thanks.
Thanks for the reply. Yes I followed the instructions from this wiki page before I asked for help. I try example on Alfresco and works for me, but when I try same on Alfresco Share there is no new web scripts when I refresh web scripts list.
I add this:
1. New "web-scripts-application-context.xml" file in tomcat/webapps/share/WEB-INF/classes/org/springframework/extensions/webscripts/.
<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'><beans> <bean id="webscript.org.springframework.extensions.webscripts.simple.get" class="org.alfresco.module.demoscripts.SimpleWebScript" parent="webscript" /></beans>
2. "simple.get.desc.xml" file in tomcat/webapps/share/WEB-INF/classes/org/springframework/extensions/webscripts/.
<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="html"/> </webscript>
3. "simple.get.html.ftl" file at same location.
<html> <head> <title>Hello World</title> </head> <body> ${hello} </body> </html>
4. "SimpleWebScript.jar" file in tomcat/webapps/share/WEB-INF/lib/.
package org.alfresco.module.demoscripts;import java.util.HashMap;import java.util.Map;import org.springframework.extensions.webscripts.DeclarativeWebScript;import org.springframework.extensions.webscripts.Status;import org.springframework.extensions.webscripts.WebScriptRequest;public class SimpleWebScript extends DeclarativeWebScript { public SimpleWebScript() { } protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) { Map<String, Object> model = new HashMap<String, Object>(); model.put("hello", "Hello World"); return model; } }
Thanks.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2011 04:52 AM
It looks like the problem is that you've placed your WebScript package folders (for the .desc.xml and .html.ftl) directly into the classpath which is not a location looked in by default. If you place those files under "classes/webscripts" files (e.g. in tomcat/webapps/share/WEB-INF/classes/webscripts/org/springframework/extensions/webscripts/) then it should work.
Regards,
Dave
Regards,
Dave
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2011 03:40 PM
Thanks a lot, your reply was helpful, now works in Alfrescno Share too.
Thanks again.
Thanks again.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2011 05:05 AM
No problem - happy to help!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2013 03:16 PM
my helloworld.get.html.ftl,
${hello}
my helloworld.get.desc.xml
<webscript>
<shortname>Hello World</shortname>
<description>Hello world web script</description>
<url>/helloworld?name={nameArgument}</url>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>
My java:
package org.alfresco.module.demoscripts;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.alfresco.service.cmr.repository.NodeRef.Status;
import org.json.JSONException;
import org.json.JSONObject;
public class SimpleWebScript extends DeclarativeWebScript {
public SimpleWebScript() {
}
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("hello", "Hello World");
System.out.println("hello1");
return model;
}
}
My web-scripts-application-context.xml in C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>
<beans>
<bean id="webscript.org.alfresco.demo.simple.get" class="org.alfresco.module.demoscripts.SimpleWebScript"
parent="webscript" />
</beans>
The error I got:
13:26:46,907 ERROR [freemarker.runtime] Template processing error: "Expression hello is undefined on line 1, column 25 in simple.get.html.ftl."
Expression hello is undefined on line 1, column 25 in simple.get.html.ftl.
The problematic instruction:
———-
==> ${hello} [on line 1, column 23 in simple.get.html.ftl]
I don't have luck today.
${hello}
my helloworld.get.desc.xml
<webscript>
<shortname>Hello World</shortname>
<description>Hello world web script</description>
<url>/helloworld?name={nameArgument}</url>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>
My java:
package org.alfresco.module.demoscripts;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.alfresco.service.cmr.repository.NodeRef.Status;
import org.json.JSONException;
import org.json.JSONObject;
public class SimpleWebScript extends DeclarativeWebScript {
public SimpleWebScript() {
}
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("hello", "Hello World");
System.out.println("hello1");
return model;
}
}
My web-scripts-application-context.xml in C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>
<beans>
<bean id="webscript.org.alfresco.demo.simple.get" class="org.alfresco.module.demoscripts.SimpleWebScript"
parent="webscript" />
</beans>
The error I got:
13:26:46,907 ERROR [freemarker.runtime] Template processing error: "Expression hello is undefined on line 1, column 25 in simple.get.html.ftl."
Expression hello is undefined on line 1, column 25 in simple.get.html.ftl.
The problematic instruction:
———-
==> ${hello} [on line 1, column 23 in simple.get.html.ftl]
I don't have luck today.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2013 05:38 AM
Your context file should be in /web-extention and not /extention this one is for Alfresco explorer wish that can help.