cancel
Showing results for 
Search instead for 
Did you mean: 

I want to query this picture category .

nyszhangyong
Champ in-the-making
Champ in-the-making
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...[/img]
[img]http://b103.photo.store.qq.com/psb?/V13vOWFy018Dz1/vmnb6Jruv*BKlFazQGzZ4CkqTq0cbsnS5oxxAAFaOGw!/b/YV...[/img]
[img]http://b97.photo.store.qq.com/psb?/V13vOWFy018Dz1/vattcFHylYOZIuwzREYa65*D7TN.vI4auk1C9BW5UKk!/b/YQq...[/img]
[img]http://b103.photo.store.qq.com/psb?/V13vOWFy018Dz1/zt*riaEWqB0MrsMV1fFStP00GKIFRAwN88FujHxJL6U!/b/Yb...[/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();
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
One potential problem with your code is that you are assuming the node has been categorized, which may not be the case. If the node does not have the generalclassifiable aspect added your code will break where you reference node.properties['cm:categories'].

One way to defend against that problem is to add a hasAspect check, like this:
if (node.hasAspect('cm:generalclassifiable'))

That does not explain why your title is blank, but it may explain why your code is throwing an exception.

Also, as I pointed out in your other thread, please enclose long exceptions and code listings with
tags. I have edited this post to show you how to do it. You will greatly increase your chances of getting responses in the future if you follow this convention in the forums.

Nice screenshots, BTW.

Jeff

nyszhangyong
Champ in-the-making
Champ in-the-making
Thank Jeff,
read your reply ,
I again conducted a careful examination ,
I confirm that the node has been classified ,as shown below :
Please continue to help my analysis, thanks again.

[img]http://b101.photo.store.qq.com/psb?/V13vOWFy018Dz1/x46gHAihXAdargZI1PbXKGDsHzrvsznLFPhdS0JgVGs!/b/Yc...[/img]

[img]http://b101.photo.store.qq.com/psb?/V13vOWFy018Dz1/s3SS2b8DgC4FMGm5BARRN1o7G4aNzv2fEZwGI6qV7xE!/b/YT...[/img]

nyszhangyong
Champ in-the-making
Champ in-the-making
Thanks Jeff,
Thank you for the reminder,
The two issues have been resolved.

jpotts
World-Class Innovator
World-Class Innovator
All of that work and you aren't going to tell us what the problem was? Don't keep it a secret!

Jeff

nyszhangyong
Champ in-the-making
Champ in-the-making
The solution is :
node.properties['cm:categories'] This line of code returns an array of objects .
I have it resolved,Source code as follows:

scenePicQuery.get.json.ftl


<#escape x as jsonUtils.encodeJSONString(x)>
{
   "nodeAttributeDetail":
    [
     {
         "nodeUrl": "${data.nodeAttributeDetail.nodeUrl}",
         "nodeTitle": "${data.nodeAttributeDetail.nodeTitle}",
         "nodeCategories": "${data.nodeAttributeDetail.nodeTitle}"
     }
    ][b],
   "sceneArrayItems":
   [
      <#list data.nodeAttributeDetail.nodeCategoriesa as sceneObject>
      {
         "id": "${sceneObject.name}"
      }<#if sceneObject_has_next>,</#if>
      </#list>
   ][/b]
}
</#escape>


The title of the solution is :
I re-download the “alfresco-community-4.0.d-installer-win-x32.exe”, and re- installation , then the value of the title is displayed .

I used to use alfresco program to compile and deploy .