AnsweredAssumed Answered

I want to query this picture category .

Question asked by nyszhangyong on Jun 27, 2012
Latest reply on Jun 29, 2012 by nyszhangyong
hello

Why the query picture category , an exception is thrown ?

The version of the software I use is 4.0.d.

Please help me to analyze the reasons , or modify the code to solve the problems described below Thank you very much !

[img]http://b100.photo.store.qq.com/psb?/V13vOWFy018Dz1/gi*rQBRdowdg3A6FUI5xTbaiROxC3dTZPXnPtAmASiI!/b/YS.qrjuYbAAAYi6fqzubawAA[/img]
[img]http://b103.photo.store.qq.com/psb?/V13vOWFy018Dz1/vmnb6Jruv*BKlFazQGzZ4CkqTq0cbsnS5oxxAAFaOGw!/b/YVfScz3UQgAAYnynZz0WQgAA[/img]
[img]http://b97.photo.store.qq.com/psb?/V13vOWFy018Dz1/vattcFHylYOZIuwzREYa65*D7TN.vI4auk1C9BW5UKk!/b/YQql1Tm.iAAAYggb1DnLiAAA[/img]
[img]http://b103.photo.store.qq.com/psb?/V13vOWFy018Dz1/zt*riaEWqB0MrsMV1fFStP00GKIFRAwN88FujHxJL6U!/b/Yb.vaj2uQgAAYm3Ucz3GQgAA[/img]


Exception as follows :

{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "05270001 Wrapped Exception (with status template): 05270088 Error during processing of the template 'Error on line 1, column 15 in testScenePicQuery\/testScenePicQuery.get.json.ftl\nExpecting a string, date or number here, Expression jsonUtils.encodeJSONString(x) is instead a freemarker.template.SimpleSequence'. Please contact your system administrator.", 
  "exception" : "org.springframework.extensions.webscripts.WebScriptException - 05270001 Wrapped Exception (with status template): 05270088 Error during processing of the template 'Error on line 1, column 15 in testScenePicQuery\/testScenePicQuery.get.json.ftl\nExpecting a string, date or number here, Expression jsonUtils.encodeJSONString(x) is instead a freemarker.template.SimpleSequence'. Please contact your system administrator.",
 
  "callstack" :
  [
       ""      ,"freemarker.core.NonStringException: Error on line 1, column 15 in testScenePicQuery\/testScenePicQuery.get.json.ftl\nExpecting a string, date or number here, Expression jsonUtils.encodeJSONString(x) is instead a freemarker.template.SimpleSequence"
      ,"freemarker.core.Expression.getStringValue(Expression.java:126)"
      ,"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.EscapeBlock.accept(EscapeBlock.java:84)"
      ,"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:876)"
      ,"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:414)"
      ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:476)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:514)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:330)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:372)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)"
      ,"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:433)"
      ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)"
      ,"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:286)"
      ,"org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:857)"
      ,"org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565)"
      ,"org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)"
      ,"java.lang.Thread.run(Unknown Source)"
      ,"org.alfresco.service.cmr.repository.TemplateException: 05270088 Error during processing of the template 'Error on line 1, column 15 in testScenePicQuery\/testScenePicQuery.get.json.ftl\nExpecting a string, date or number here, Expression jsonUtils.encodeJSONString(x) is instead a freemarker.template.SimpleSequence'. Please contact your system administrator."
      ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:206)"
      ,"org.springframework.extensions.webscripts.WebScriptException: 05270001 Wrapped Exception (with status template): 05270088 Error during processing of the template 'Error on line 1, column 15 in testScenePicQuery\/testScenePicQuery.get.json.ftl\nExpecting a string, date or number here, Expression jsonUtils.encodeJSONString(x) is instead a freemarker.template.SimpleSequence'. Please contact your system administrator."
      ,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1047)"

  ],
 
  "server" : "Community v4.1.0 (@build-number@) schema 6,006",
  "time" : "2012-6-27 16:30:42"
}



The source code is as follows:


sampleQuery.get.desc.xml
<webscript>
      <shortname>scenePicQuery</shortname>
      <description>scene pic query</description>
      <url>/testSample/sampleQuery</url>
      <authentication>user</authentication>
      <negotiate accept="text/html">html</negotiate>
      <negotiate accept="application/json">json</negotiate>
</webscript>

sampleQuery.get.js
<#escape x as jsonUtils.encodeJSONString(x)>
{
   "nodeAttributeDetail":
    [
     {
         "nodeUrl": "${data.nodeAttributeDetail.nodeUrl}",
         "nodeTitle": "${data.nodeAttributeDetail.nodeTitle}",
         "nodeCategories": "${data.nodeAttributeDetail.nodeCategories}"
     }
    ]
}
</#escape>

sampleQuery.get.json.ftl
const DEFAULT_MAX_RESULTS = 500;
function main()
{
     var alfQuery =
     ' PATH:"/app:company_home/app:guest_home//*"' +
     ' AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}thumbnail"' +
     ' AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}folder"';
     var queryDef = {
          query: alfQuery,
          language: "fts-alfresco",
          page: {maxItems: DEFAULT_MAX_RESULTS},
          templates: []
      };
     var nodes = search.query(queryDef),
         item;
     for (var i = 0, j = nodes.length; i < j; i++){
          // Create core object
          node = nodes[i];
          item ={
                nodeRef: node.nodeRef.toString(),
                type: node.typeShort,
                name: node.name,
                nodeUrl:node.url,
                nodeTitle: node.properties["cm:title"],
                nodeCategories:node.properties["cm:categories"]
          };
       }
      var nodeAttributeDetail;
           nodeAttributeDetail={
               nodeUrl:item.nodeUrl,
               nodeTitle:item.nodeTitle,
               nodeCategories:item.nodeCategories
           };
       model.data = {
           nodeAttributeDetail:nodeAttributeDetail
       };
}
main();

Outcomes