cancel
Showing results for 
Search instead for 
Did you mean: 

Error Expected hash

cperez
Champ in-the-making
Champ in-the-making
I am having an issue with accessing the file in ftl. I use a webscript to show the content of a specific file after search it.

This is the error when i search the file with http://localhost:8080/alfresco/service/showContent?name=doc3.pdf:
<cite>
500 Description:   An error inside the HTTP server which prevented it from fulfilling the request.

Message:   Wrapped Exception (with status template): Error during processing of the template 'Expected hash. fichero evaluated instead to freemarker.template.SimpleSequence on line 9, column 15 in showContent.get.html.ftl.'. Please contact your system administrator.
</cite>

I have the error in the next piece of code where I use "file" in the tithe within the head:


<html>
   <head>
      <title>${file.name}</title>
   </head>
   <body>
      File: ${file.name}
      <br>
      <table>
         <#if fichero.isContainer>
            <td>><td><a href="${url.serviceContext}/folder<@encodepath node=fichero/>">${fichero.name}</a>
         <#else>
            <td><td><a href="${url.serviceContext}/api/node/content/${fichero.nodeRef.storeRef.protocol}/${fichero.nodeRef.storeRef.identifier}/${fichero.nodeRef.id}/${fichero.name?url}">${fichero.name}</a>
         </#if>
      </table>
      <td><td><a href="${url.serviceContext}/api/node/content/${fichero.nodeRef.storeRef.protocol}/${fichero.nodeRef.storeRef.identifier}/${fichero.nodeRef.id}/${fichero.name?url}">${child.name}</a>
   </body>
</html>



I use the next script where I save "file" in "model.file". If I use "model.foo = "example"" this work fine.


var spath="'+PATH:\""+companyhome.displayPath +"//*\" + ";
var scontent="@\\{http\\://www.alfresco.org/model/content/1.0\\}content.mimetype:application/pdf + ";
var qname = "@cm\\:name:" + args.name;
var strq=spath+scontent+qname;

var content=search.luceneSearch(strq);

model.foo = "example";
model.fichero = content;


And this is the xml file of the script


<webscript>
   <shortname>Show Content</shortname>
   <description>Show user specific content identified by parameters </description>
   <url>/showContent?name={nameArgument}</url>
   <authentication>user</authentication>
</webscript>


can anyone hel my??

Thanks a lot in advance!!
1 REPLY 1

kaynezhang
World-Class Innovator
World-Class Innovator
Search.luceneSearch will return an array object instead of single object.Even if your search will return single object,luceneSearch will wrap it to an array.
And apparently the array object  does not understand the isContainer property.