cancel
Showing results for 
Search instead for 
Did you mean: 

Issue wit Atom response file for listing folders in Alfresco

suryabadami
Champ in-the-making
Champ in-the-making
My response file for listing the folders in Alfresco looks like this (folder.get.atom)

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <generator version="${server.version}">Alfresco (${server.edition})</generator>
  <title>Folder: ${folder.displayPath}/${folder.name?xml}</title>
  <updated>${xmldate(date)}</updated>
  <icon>${absurl(url.context)}/images/logo/AlfrescoLogo16.ico</icon>
<#list folder.children as child>
  <entry>
    <title>${child.name?xml}</title>
    <#if child.isContainer>
      <link rel="alternate" href="${absurl(url.serviceContext)}/sample/folder<@encodepath node=child/>"/>
    <#else>
      <link rel="alternate" href="${absurl(url.serviceContext)}/api/node/content/${child.nodeRef.storeRef.protocol}/${child.nodeRef.storeRef.identifier}/${child.nodeRef.id}/${child.name?url}"/>
    </#if>
    <icon>${absurl(url.context)}${child.icon16}</icon>
    <id>urn:uuid:${child.id}</id>
<updated>${xmldate(child.properties.modified)}</updated>
    <summary>${child.properties.description?xml!""}</summary>
    <author>
      <name>${child.properties.creator?xml}</name>
    </author>
  </entry>
</#list>
</feed>
<#macro encodepath node><#if node.parent?exists><@encodepath node=node.parent/>/${node.name?url}</#if></#macro>
*************************************************************************************************************************************************************************************
Discription file (folder.get.desc.xml)

<webscript>
<shortname>Folder Listing Sample</shortname>
<description>
Sample demonstrating the listing of folder contents
</description>
<url>/sample/folder/{path}</url>
<format default="html">argument</format>
<authentication>guest</authentication>
<transaction>required</transaction>
</webscript>
*************************************************************************************************************************************************************************************
When i invoke this webscript http://localhost:8080/alfresco/service/sample/folder/Company%20Home?format=atom , it displays the XML response file as expected.
I want to define properties in folder.get.atom for child so that i get XML response file even for the child.

Mean to say when i invoke websrcipt using URL http://localhost:8080/alfresco/service/sample/folder/Company%20Home/Sites(Any child)?format=atom , i want to get same Xml format of response.

Please guide me with the changes(adding properties for every child) in the code  folder.get.atom to make it work in generic.
2 REPLIES 2

suryabadami
Champ in-the-making
Champ in-the-making
when i am trying to invoke using http://localhost:8080/alfresco/service/sample/folder/Company%20Home/Sites?format=atom , I am getting Web Script Status 500 - Internal Error.Below is the stack trace  

    freemarker.core.InvalidReferenceException - Expression child.properties.description is   undefined on line 18, column 16 in org/alfresco/sample/folder.get.atom.ftl.
    freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)
    freemarker.core.Expression.getStringValue(Expression.java:118)
    freemarker.core.Expression.getStringValue(Expression.java:93)      freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71)
    freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
    freemarker.core.DefaultToExpression._getAsTemplateModel(DefaultToExpression.java:100)
    freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
    freemarker.core.Expression.getStringValue(Expression.java:93)
    freemarker.core.DollarVariable.accept(DollarVariable.java:76)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.MixedContent.accept(MixedContent.java:92)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
    freemarker.core.Environment.visit(Environment.java:428)
    freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.MixedContent.accept(MixedContent.java:92)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.Environment.process(Environment.java:199)
    org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:202) 
    org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate   (AbstractWebScript.java:714)  
    org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)
    org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
    org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:400)
    org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactioHHelper.java:388)
    org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:453)
    org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:491)
    org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:316)
    org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:352)
    org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)    org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:290)
    org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:206)
    org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter (GlobalLocalizationFilter.java:58)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:235)
     org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
    org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process (Http11AprProtocol.java:579)
    org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
     java.lang.Thread.run(Thread.java:619)
      ExceptionSmiley Surprisedrg.alfresco.service.cmr.repository.TemplateException - 01296916 Error during processing of the template 'Expression child.properties.description is undefined on line 18, column 16 in org/alfresco/sample/folder.get.atom.ftl.'. Please contact your system administrator.
    org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:206)
      ExceptionSmiley Surprisedrg.springframework.extensions.webscripts.WebScriptException - 01294623 Wrapped Exception (with status template): 01296916 Error during processing of the template 'Expression child.properties.description is undefined on line 18, column 16 in org/alfresco/sample/folder.get.atom.ftl.'. Please contact your system administrator. Smiley Sad(((

mitpatoliya
Star Collaborator
Star Collaborator
There could be problem with

${child.properties.description?xml!""}

Have you tried removing  ?xml!"" suffix?