09-01-2009 01:30 AM
public class RandomSelectWebScript extends AbstractRepositoryWebScript
{
public void execute(WebScriptRequest req, WebScriptResponse res)
throws IOException
{
try{
// get the referenced incoming node
NodeRef rootNodeRef = new NodeRef("avm://crweb–creator/-1;www;avm_webapps;ROOT;cms;83;NL");
System.out.println("rootNodeRef:::"+rootNodeRef);
// draw a random child
NodeRef childNodeRef = randomChild(rootNodeRef);
System.out.println("childNodeRef:::"+childNodeRef);
// stream child back
output(res, childNodeRef);
}
catch(Exception e){
e.printStackTrace();
}
}
protected NodeRef randomChild(NodeRef rootNodeRef)
{
// count the number of children
NodeRef nodeRef = null;
try{
System.out.println("call randomChild:::"+rootNodeRef);
List<FileInfo> files = this.services.getFileFolderService().listFiles(rootNodeRef);
int fileCount = files.size();
System.out.println("call fileCount:::"+fileCount);
// draw random number
int draw = (int) ((double)Math.random() * (double)fileCount);
System.out.println("call draw:::"+draw);
// our draw
FileInfo fileInfo = (FileInfo) files.get(draw);
System.out.println("call fileInfo:::"+fileInfo);
nodeRef = fileInfo.getNodeRef();
System.out.println("call nodeRef:::"+nodeRef);
}
catch(Exception e){
e.printStackTrace();
}
return nodeRef;
}
protected void output(WebScriptResponse res, NodeRef nodeRef)
{
System.out.println("call output:::"+nodeRef);
ContentReader reader = this.services.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT);
// stream back
try
{
reader.getContent(res.getOutputStream());
System.out.println("call output:::"+ res.getOutputStream());
}
catch (Exception e)
{
throw new WebScriptException("Unable to stream output");
}
}
}The description xml is: <webscript>
<shortname>Streams a random content item</shortname>
<description>Streams a random content item</description>
<url>/cms/ejustice/europa/wcmcontent/random?taxid={taxid}&msid={msid}&langid={langid}</url>
<authentication>user</authentication>
<format default="">argument</format>
</webscript> and the mapping file *context.xml is <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="webscript.com.cms.ejustice.europa.wcmcontent.random.get"
class="com.ejustice.scripts.RandomSelectWebScript"
parent="webscript">
<property name="serviceRegistry" ref="ServiceRegistry" />
</bean>
</beans>Now the requirement is that I want to access this content using REST based approach in web script, providing parmeters to search the content the way it is given in this path : cms, then 83, etc –>avm://crweb–creator/-1;www;avm_webapps;ROOT;cms;83;NL. Now the problem is I want to make the user authentication for this webscript as NONE or GUEST, so that it can be even accessed by my guest users, without requiring any authentication. If I make it NONE in my description file, it doesnt allow to read the content in the AVM Node. How can I achieve it? Please help. Looking forward for your reply.09-01-2009 04:05 AM
09-01-2009 11:38 AM
09-02-2009 07:31 AM
<webscript>
<shortname>Streams a random content item</shortname>
<description>Streams a random content item</description>
<url>/cms/ejustice/europa/wcmcontent/random?taxid={taxid}&msid={msid}&langid={langid}</url>
<authentication>GUEST</authentication>
<format default="">argument</format>
</webscript> I get the following exception in my browser Broken Web Scripts
Failed to parse web script description document com/cms/ejustice/europa/wcmcontent/random.get.desc.xml ; Authentication 'GUEST' is not a valid value (classpath:alfresco/extension/templates/webscripts/com/cms/ejustice/europa/wcmcontent/random.get.desc.xml)
Infact I have invited Guest user role as reviewer on my web project where my content resides. Please Help!!!! Urgent
09-02-2009 08:19 AM
09-05-2009 02:22 AM
<webscript>
<shortname>Streams a random content item</shortname>
<description>Streams a random content item</description>
<url>/cms/ejustice/europa/wcmcontent/random?taxid={taxid}&msid={msid}&langid={langid}</url>
<authentication>guest</authentication>
<format default="">argument</format>
</webscript> and invited guest user on the web project as a contributor (the web project has been created by a user 'testuser' who has invited guest on to his web project as content contributor, but still when I call the web script through url in IE using http://localhost:8080/alfresco/service/cms/ejustice/europa/wcmcontent/random?taxid=83&msid=NL&langid..., I still get the authentication window, [img]C:\Documents%20and%20Settings\vermaR\My%20Documents\My%20Pictures\webscriptAuth.JPG[/img]though the authentication level is set to guest, even if I give guest as username and password it gives me following access denied error.org.alfresco.repo.security.permissions.AccessDeniedException: Access Denied. You do not have the appropriate permissions to perform this operation.
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:53)
11:47:43,845 ERROR [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:275)
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
11:47:43,845 ERROR [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
11:47:43,845 ERROR [STDERR] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
11:47:43,845 ERROR [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
11:47:43,845 ERROR [STDERR] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
11:47:43,845 ERROR [STDERR] at $Proxy90.getReader(Unknown Source)
11:47:43,845 ERROR [STDERR] at com.ejustice.scripts.RandomSelectWebScript.output(RandomSelectWebScript.java:79)
11:47:43,845 ERROR [STDERR] at com.ejustice.scripts.RandomSelectWebScript.execute(RandomSelectWebScript.java:37)
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:328)
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:322)
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:229)
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:377)
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:399)
11:47:43,845 ERROR [STDERR] at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:282)
11:47:43,845 ERROR [STDERR] at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:294)
11:47:43,845 ERROR [STDERR] at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:172)
11:47:43,845 ERROR [STDERR] at org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)
11:47:43,845 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
11:47:43,845 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
11:47:43,845 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
11:47:43,845 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
11:47:43,845 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
11:47:43,845 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
11:47:43,845 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
11:47:43,845 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
11:47:43,855 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
11:47:43,855 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
11:47:43,855 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
11:47:43,855 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
11:47:43,855 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
11:47:43,855 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
11:47:43,855 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
11:47:43,855 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
11:47:43,855 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
11:47:43,855 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
11:47:43,855 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
11:47:43,855 ERROR [STDERR] Caused by: net.sf.acegisecurity.AccessDeniedException: Access is denied.
11:47:43,855 ERROR [STDERR] at net.sf.acegisecurity.vote.AffirmativeBased.decide(AffirmativeBased.java:86)
11:47:43,855 ERROR [STDERR] at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:394)
11:47:43,855 ERROR [STDERR] at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
11:47:43,855 ERROR [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
11:47:43,855 ERROR [STDERR] at org.alfresco.repo.model.ml.MLContentInterceptor.invoke(MLContentInterceptor.java:91)
11:47:43,855 ERROR [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
11:47:43,855 ERROR [STDERR] at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
11:47:43,855 ERROR [STDERR] … 38 more
09-17-2009 03:38 PM
http://localhost:8080/alfresco/service/cms/ejustice/europa/wcmcontent/random?taxid=83&msid=NL&langid...
09-17-2009 03:48 PM
09-17-2009 04:05 PM
09-23-2009 09:43 AM
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.