cancel
Showing results for 
Search instead for 
Did you mean: 

Knowledge Base Search non reconnu

clemf
Champ in-the-making
Champ in-the-making
Bonjour à tous,

Je teste actuellement le script Knowledge Base Search et Knowledge Base Create.

J'ai suivi la procédure disponible dans la documentation Alfreso ici : http://docs.alfresco.com/3.4/index.jsp?topic=%2Fcom.alfresco.Enterprise_3_4_0.doc%2Ftasks%2Fws-kb-se...

J'ai donc créé le script de création qui fonctionne bien (après ajout du modèle pour le préfixe kb : http://docs.alfresco.com/3.4/index.jsp?topic=%2Fcom.alfresco.Enterprise_3_4_0.doc%2Ftasks%2Fkb-defin...) :
Created article6 within site 'kbtest'.

En revanche lorsque je veux faire fonctionner le script de recherche il ne le trouve pas, ou ne le reconnait pas comme un web script.

Voici le contenu des mes fichiers, je les ai directement pris à partir de la doc Alfresco :

kb-search.get.desc.xml :
<webscript>
   <shortname>Knowledge Base Search</shortname>
   <description>Searches for knowledge base articles</description>
   <url>/slingshot/knowledgebase/search/site/{site}?maxResults={maxResults?}</url>
   <format default="json">argument</format>
   <authentication>user</authentication>
</webscript>
kb-search.get.js :
/**
* KnowledgeBase Search Web Script
*
* Inputs:
*   optional:  siteId = site ID to search in
*   optional:  maxResults = max items to return.
*
* Outputs:
*   data.items/data.error - object containing list of search results
*
* If siteId is null, the entire repository will be searched.
*/

/**
* Search constants
*/
const DEFAULT_MAX_RESULTS = 500;
const SITES_SPACE_QNAME_PATH = "/app:company_home/st:sites/";

/**
* Performs a search for knowledge base articles in a site
*
* @method doSearch
* @param siteId {string} The site to search in (or null to search full repository)
* @param maxResults {int} Maximum number of results to return
* @return {array} Articles matching the query in the same format that toArticle() method returns
*/
function doSearch(siteId, maxResults)
{
   // The initial template
   var alfQuery = 'ASPECT:"{http://www.alfresco.org/model/knowledgebase/1.0}article"' +
      ' AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}thumbnail"' +
      ' AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}folder"';

   // if we have a siteId, append it into the query
   if (siteId != null)
   {
      alfQuery += ' AND PATH:"' + SITES_SPACE_QNAME_PATH + '/cm:' + siteId + '/cm:documentLibrary//*"';
   }

   // 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[i];
      item =
      {
         nodeRef: node.nodeRef.toString(),
         type: node.typeShort,
         name: node.name,
         title: node.properties["cm:title"],
         description: node.properties["cm:description"],
         modifiedOn: node.properties["cm:modified"],
         modifiedByUser: node.properties["cm:modifier"],
         createdOn: node.properties["cm:created"],
         createdByUser: node.properties["cm:creator"],
         author: node.properties["cm:author"],
         nodeDBID: node.properties["sys:node-dbid"],
         properties: {}
      };

      // Calculate display names for users
      var person = people.getPerson(item.modifiedByUser);
      item.modifiedBy = (person != null ? (person.properties.firstName + " " + person.properties.lastName) : item.modifiedByUser);
      person = people.getPerson(item.createdByUser);
      item.createdBy = (person != null ? (person.properties.firstName + " " + person.properties.lastName) : item.createdByUser);

      // Add the Article namespace properties
      for (var k in node.properties)
      {
         if (k.match("^{http://www.alfresco.org/model/knowledgebase/1.0}") == "{http://www.alfresco.org/model/knowledgebase/1.0}")
         {
            item.properties["kb_" + k.split('}')[1]] = node.properties[k];
         }
      }
      articles.push(item);
   }

   return articles;
}

/**
* The WebScript bootstrap method
*
* @method main
*/
function main()
{
   // Gather webscript parameters
   var siteId = url.templateArgs.site;
   var maxResults = (args.maxResults !== null) ? parseInt(args.maxResults) : DEFAULT_MAX_RESULTS;

   // Perform search
   var articles = doSearch(siteId, maxResults);

   // Generate model from results
   model.data = {
      items: articles
   };
}

main();
kb-search.get.json.ftl :
<#escape x as jsonUtils.encodeJSONString(x)>
{
   "items":
   [
      <#list data.items as item>
      {
         "nodeRef": "${item.nodeRef}",
         "type": "${item.type}",
         "name": "${item.name}",
         "title": "${item.title!''}",
         "description": "${item.description!''}",
         "modifiedOn": "${xmldate(item.modifiedOn)}",
         "modifiedByUser": "${item.modifiedByUser}",
         "modifiedBy": "${item.modifiedBy}",
         "createdOn": "${xmldate(item.createdOn)}",
         "createdByUser": "${item.createdByUser}",
         "createdBy": "${item.createdBy}",
         "author": "${item.author!''}",
         "nodeDBID": "${item.nodeDBID}",
         "properties":
         {
         <#assign first=true>
         <#list item.properties?keys as k>
            <#if item.properties[k]??>
               <#if !first>,<#else><#assign first=false></#if>"${k}":
               <#assign prop = item.properties[k]>
               <#if prop?is_date>"${xmldate(prop)}"
               <#elseif prop?is_boolean>${prop?string("true", "false")}
               <#elseif prop?is_enumerable>[<#list prop as p>"${p}"<#if p_has_next>, </#if></#list>]
               <#elseif prop?is_number>${prop?c}
               <#else>"${prop}"
               </#if>
            </#if>
         </#list>
         }
      }<#if item_has_next>,</#if>
      </#list>
   ]
}
</#escape>

J'obtiens une erreur 500 lorsque je me rend sur http://localhost:8080/alfresco/s/slingshot/knowledgebase/search/site/kbtest :
{

    -
    status: {
        code: 500
        name: "Internal Error"
        description: "An error inside the HTTP server which prevented it from fulfilling the request."
    }
    message: "04250027 Wrapped Exception (with status template): 04250052 Failed to execute script '/org/example/kb-search.get.js (in repository store workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web)': 04250051 Failed to execute search: ASPECT:"{http://www.alfresco.org/model/knowledgebase/1.0}article" AND PATH:"/app:company_home/st:sites//cm:kbtest/cm:documentLibrary//*" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}thumbnail" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}folder""
    exception: "org.springframework.extensions.webscripts.WebScriptException - 04250027 Wrapped Exception (with status template): 04250052 Failed to execute script '/org/example/kb-search.get.js (in repository store workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web)': 04250051 Failed to execute search: ASPECT:"{http://www.alfresco.org/model/knowledgebase/1.0}article" AND PATH:"/app:company_home/st:sites//cm:kbtest/cm:documentLibrary//*" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}thumbnail" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}folder""
    -
    callstack: [
        ""
        "org.alfresco.error.AlfrescoRuntimeException: 04250050 Unknown aspect specified in query: {http://www.alfresco.org/model/knowledgebase/1.0}article"
        "org.alfresco.repo.search.impl.lucene.LuceneQueryParser.createAspectQuery(LuceneQueryParser.java:1069)"
        "org.alfresco.repo.search.impl.lucene.LuceneQueryParser.getFieldQuery(LuceneQueryParser.java:877)"
        "org.alfresco.repo.search.impl.lucene.LuceneQueryParser.getFieldQuery(LuceneQueryParser.java:435)"
        "org.alfresco.repo.search.impl.querymodel.impl.lucene.functions.LuceneFTSPhrase.addComponent(LuceneFTSPhrase.java:76)"
        "org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneFunctionalConstraint.addComponent(LuceneFunctionalConstraint.java:58)"
        "org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneConjunction.addComponent(LuceneConjunction.java:70)"
        "org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQuery.buildQuery(LuceneQuery.java:106)"
        "org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryEngine.executeQuery(LuceneQueryEngine.java:177)"
        "org.alfresco.repo.search.impl.lucene.LuceneAlfrescoFtsQueryLanguage.executQuery(LuceneAlfrescoFtsQueryLanguage.java:111)"
        "org.alfresco.repo.search.impl.lucene.ADMLuceneSearcherImpl.query(ADMLuceneSearcherImpl.java:511)"
        "org.alfresco.repo.search.SearcherComponent.query(SearcherComponent.java:78)"
        "sun.reflect.GeneratedMethodAccessor1408.invoke(Unknown Source)"
        "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)"
        "java.lang.reflect.Method.invoke(Method.java:597)"
        "org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)"
        "org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)"
        "org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)"
        "net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)"
        "org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
        "org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)"
        "org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
        "org.alfresco.repo.audit.AuditMethodInterceptor.proceedWithAudit(AuditMethodInterceptor.java:217)"
        "org.alfresco.repo.audit.AuditMethodInterceptor.proceed(AuditMethodInterceptor.java:184)"
        "org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:137)"
        "org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
        "org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)"
        "org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
        "org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)"
        "$Proxy36.query(Unknown Source)"
        "org.alfresco.repo.jscript.Search.query(Search.java:742)"
        "org.alfresco.repo.jscript.Search.query(Search.java:628)"
        "sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
        "sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)"
        "sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)"
        "java.lang.reflect.Method.invoke(Method.java:597)"
        "org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)"
        "org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)"
        "org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)"
        "org.mozilla.javascript.gen.c37._c1(workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web/org/example/kb-search.get.js:45)"
        "org.mozilla.javascript.gen.c37.call(workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web/org/example/kb-search.get.js)"
        "org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)"
        "org.mozilla.javascript.gen.c37._c2(workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web/org/example/kb-search.get.js:106)"
        "org.mozilla.javascript.gen.c37.call(workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web/org/example/kb-search.get.js)"
        "org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)"
        "org.mozilla.javascript.gen.c37._c0(workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web/org/example/kb-search.get.js:114)"
        "org.mozilla.javascript.gen.c37.call(workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web/org/example/kb-search.get.js)"
        "org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)"
        "org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)"
        "org.mozilla.javascript.gen.c37.call(workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web/org/example/kb-search.get.js)"
        "org.mozilla.javascript.gen.c37.exec(workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web/org/example/kb-search.get.js)"
        "org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:472)"
        "org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:190)"
        "org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:282)"
        "org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)"
        "org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:981)"
        "org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)"
        "org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:383)"
        "org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)"
        "org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436)"
        "org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466)"
        "org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304)"
        "org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)"
        "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.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)"
        "org.alfresco.error.AlfrescoRuntimeException: 04250051 Failed to execute search: ASPECT:"{http://www.alfresco.org/model/knowledgebase/1.0}article" AND PATH:"/app:company_home/st:sites//cm:kbtest/cm:documentLibrary//*" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}thumbnail" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}folder""
        "org.alfresco.repo.jscript.Search.query(Search.java:758)"
        "org.alfresco.scripts.ScriptException: 04250052 Failed to execute script '/org/example/kb-search.get.js (in repository store workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web)': 04250051 Failed to execute search: ASPECT:"{http://www.alfresco.org/model/knowledgebase/1.0}article" AND PATH:"/app:company_home/st:sites//cm:kbtest/cm:documentLibrary//*" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}thumbnail" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}folder""
        "org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:194)"
        "org.springframework.extensions.webscripts.WebScriptException: 04250027 Wrapped Exception (with status template): 04250052 Failed to execute script '/org/example/kb-search.get.js (in repository store workspace://SpacesStore/Espace racine/Dictionnaire de données/Extensions de script Web)': 04250051 Failed to execute search: ASPECT:"{http://www.alfresco.org/model/knowledgebase/1.0}article" AND PATH:"/app:company_home/st:sites//cm:kbtest/cm:documentLibrary//*" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}thumbnail" AND NOT TYPE:"{http://www.alfresco.org/model/content/1.0}folder""
        "org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:758)"
    ]
    server: "Community v3.4.0 (d 3370) schema 4 113"
    time: "25 mai 2011 17:42:35"

}

Merci d'avance.
3 REPLIES 3

cleseach
Star Contributor
Star Contributor
Bonjour,

Votre log d'erreur précise :
Unknown aspect specified in query: {http://www.alfresco.org/model/knowledgebase/1.0}article

Il reste visiblement encore une erreur dans la définition de vos types.

Cordialement,
Charles Le Seac'h

clemf
Champ in-the-making
Champ in-the-making
Bonjour, et merci pour votre réponse.

J'ai recréé le modèle tout entier mais cette erreur persiste, voici le contenu du fichier knowledgeBaseModel.xml :
<model name="kb:contentmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <!– Introduce the model with the header –>
   <description>Knowledge Base Content Model</description>
   <author>alfresco_professional</author>
   <version>1.0</version>
   <imports>
      <!– Import out-of-the-box content models –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>
   <namespaces>
      <!– Define the namespace –>
      <namespace uri="http://www.example.org/knowledgebase" prefix="kb"/>
   </namespaces>
   <constraints>
      <!– Define standalone constraints –>
      <constraint name="kb:attachmenttype_constraint" type="LIST">
         <parameter name="allowedValues">
            <list>
               <value>Patch</value>
               <value>Sample</value>
               <value>Documentation</value>
            </list>
         </parameter>
      </constraint>
      <constraint name="kb:status_constraint" type="LIST">
         <parameter name="allowedValues">
            <list>
               <value>Draft</value>
               <value>Pending Approval</value>
               <value>Current</value>
               <value>Archived</value>
            </list>
         </parameter>
      </constraint>
      <constraint name="kb:articletype_constraint" type="LIST">
         <parameter name="allowedValues">
            <list>
               <value>Any</value>
               <value>Article</value>
               <value>FAQ</value>
               <value>White Paper</value>
            </list>
         </parameter>
      </constraint>
   </constraints>
   <types>
      <!– Define the attachment type –>
      <type name="kb:attachment">
         <title>Attachment</title>
         <parent>cm:content</parent>
         <properties>
            <property name="kb:attachmenttype">
               <title>Attachment Type</title>
               <type>d:text</type>
               <default>Sample</default>
               <constraints>
                  <constraint ref="kb:attachmenttype_constraint" />
               </constraints>
            </property>
         </properties>
      </type>
   </types>
   <aspects>
      <!– Define the article aspect –>
      <aspect name="kb:article">
         <title>Knowledge Base Article</title>
         <properties>
            <property name="kb:articletype">
               <title>Article Type</title>
               <type>d:text</type>
               <default>Article</default>
               <constraints>
                  <constraint type="LIST">
                     <parameter name="allowedValues">
                        <list>
                           <value>Any</value>
                           <value>Article</value>
                           <value>FAQ</value>
                           <value>White Paper</value>
                        </list>
                     </parameter>
                  </constraint>
               </constraints>
            </property>
         </properties>
         <associations>
            <child-association name="kb:artifacts">
               <target>
                  <class>kb:attachment</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
               <duplicate>true</duplicate>
            </child-association>
            <association name="kb:related">
               <title>Related Articles</title>
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>kb:article</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
         </associations>
      </aspect>
   </aspects>
</model>

J'ai créé ce modèle en suivant cette documentation.

Pourquoi la kb create fonctionne-t-il alors que le kb search non ?

Merci d'avance.

cleseach
Star Contributor
Star Contributor
Bonjour,

Dans votre fichier de modèle, vous définissez le préfixe kb de la manière suivante :

<namespaces>
  <!– Define the namespace –>
  <namespace uri="http://www.example.org/knowledgebase" prefix="kb"/>
</namespaces>

Ceci signifie que kb représente l'uri http://www.example.org/knowledgebase.

Comme l'indique l'erreur identifiée dans mon précédent message, vorte webscript utilise l'uri http://www.alfresco.org/model/knowledgebase/1.0… qui ne correspond à rien de connu pour Alfresco.


Cordialement,
Charles Le Seac'h