cancel
Showing results for 
Search instead for 
Did you mean: 

How to get this picture URL and category .

nyszhangyong
Champ in-the-making
Champ in-the-making
hello

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

I uploaded a picture, and I set up a category for this picture , now I want to get to this URL and category of picture , I would like to get the URL and category inside in webscript code , but I do not know how to modify the following code, please help me modify the code below , thank you very much !


function doSearch()
{
// The initial template
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"';

// Perform fts-alfresco language query for articles
var queryDef = {
query: alfQuery,
language: "fts-alfresco",
page: {maxItems: maxResults},
templates: []
};

// Get article nodes
var nodes = search.query(queryDef),
articles = [],
item;

// Turn nodes into article objects
for (var i = 0, j = nodes.length; i < j; i++)
{
// Create core object
node = nodes;
item =
{
nodeRef: node.nodeRef.toString(),
type: node.typeShort,
name: node.name,
title: node.properties["cm:title"]
};
}

}
nyszhangyong

Posts: 2
Joined: 11 Jun 2012, 04:15
Alfresco Version: other

0 Points (What is this?)
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
The categories live in the cm:categories property, so you'd get them like this:
node.properties['cm:categories']

There are three URLs available: the content stream, the download URL, and the webDAV URL, which are:
node.url
node.downloadUrl
node.webdavUrl

All of this is covered in detail in the official documentation and the JavaScript wiki page.

Jeff

nyszhangyong
Champ in-the-making
Champ in-the-making
Thanks Jeff,

According to your description ,

I have to get the URL of the picture .


However, when the query image category, the " testScenePicQuery.get.json.ftl" file throw an exception , as follows :

The testScenePicQuery.get.json.ftl file reads as follows :

<#escape x as jsonUtils.encodeJSONString(x)>
{
   "receiveParameters":
    [
     {
         "oneParameter": "${data.receiveParametersItems.oneParameterValue}",
         "twoParameter": "${data.receiveParametersItems.twoParameterValue}",
         "threeParameter": "${data.receiveParametersItems.threeParameterValue}"
     }
    ]
}
</#escape>



"TestScenePicQuery.get.json.ftl" file exceptions thrown by the following :

{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "05270009 Wrapped Exception (with status template): 05270152 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 - 05270009 Wrapped Exception (with status template): 05270152 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: 05270152 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: 05270009 Wrapped Exception (with status template): 05270152 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 11:07:23"
}

jpotts
World-Class Innovator
World-Class Innovator
I can't help you debug your freemarker because you did not include your controller JavaScript. The freemarker you included here does not appear to be related to the controller you posted in your original post because it is referencing variables that I do not see in your earlier controller's model.

Also, it would clean up your posts significantly if you would wrap your code in
tags.

Jeff