[Alfresco Share] Aspect personnalisé

cancel
Showing results for 
Search instead for 
Did you mean: 
lamba
Active Member

[Alfresco Share] Aspect personnalisé

Salut tout le monde,

j'essaie l'exemple suivant http://blogs.alfresco.com/wp/wabson/2010/02/25/adding-custom-aspect-support-in-alfresco-share/ pour ajouter un aspect personnalisé dans Share:

J'ai créé les fichiers suivants:

kb-model.xml dans share\WEB-INF\classes\alfresco\extension
<?xml version="1.0" encoding="UTF-8"?>

<!– Definition of new Model –>

<!– The important part here is the name - Note: the use of the my: namespace
     which is defined further on in the document –>
<model name="kb:knowledgebase" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Knowledge Base Model</description>
   <author>Will Abson</author>
   <version>1.0</version>

   <!– Imports are required to allow references to definitions in other models –>
   <imports>
        <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <!– NOTE: The following namespace my.new.model should be changed to reflect your own namespace –>
   <namespaces>
      <namespace uri="http://www.alfresco.com/model/knowledgebase/1.0" prefix="kb"/>
   </namespaces>

    <aspects>

      <!– Definition of new Content Aspect: Knowledge Base Document –>
      <aspect name="kb:referencable">
         <title>Knowledge Base Referencable</title>
         <properties>
            <property name="kb:documentRef">
               <type>d:text</type>
            </property>
         </properties>
      </aspect>

   </aspects>

</model>

kb-model-context.xml dans share\WEB-INF\classes\alfresco\extension

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <!– Registration of new models –>
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/kb-model.xml</value>
            </list>
        </property>
    </bean>

</beans>

custom-slingshot-application-context.xml dans share\WEB-INF\classes\alfresco\web-extension

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

   <!– Override WebScript Messages - add slingshot application messages –>
   <bean id="webscripts.resources" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
      <property name="resourceBundles">
         <list>
            <value>webscripts.messages.webscripts</value>
            <value>alfresco.messages.slingshot</value>
            <value>alfresco.web-extension.messages.knowledgebase</value>
         </list>
      </property>
   </bean>

</beans>

share-config-custom.xml dans share\WEB-INF\classes\alfresco\web-extension

<alfresco-config>
<config evaluator="aspect" condition="kb:referencable">
    <forms>
       <form>
          <field-visibility>
             <!– inherited from cm:content –>
             <show id="cm:name" />
             <show id="cm:title" force="true" />
             <show id="cm:description" force="true" />
             <show id="mimetype" />
             <show id="cm:author" force="true" />
             <show id="size" for-mode="view" />
             <show id="cm:creator" for-mode="view" />
             <show id="cm:created" for-mode="view" />
             <show id="cm:modifier" for-mode="view" />
             <show id="cm:modified" for-mode="view" />
          
             <!–  aspect orb:referencable –>            
             <show id="kb:documentRef" />
           </field-visibility>
        
          <appearance>
             <field id="kb:documentRef" label-id="label.kb_documentRef" />
          </appearance>
       </form>
    </forms>
</config>
</alfresco-config>

knowledgebase.properties dans share\WEB-INF\classes\alfresco\messages

# Custom knowledge base messages
label.kb_documentRef=KB Reference
kb_referencable=Knowledge Base Referencable

et j'ai ajouté l'aspect dans le fichier aspects.get.config.xml pour qu'il apparait dans la fenêtre de dialogue "Manage Aspect". j'ai ajouté:

<aspect name="{http://www.alfresco.org/model/content/1.0}referencable" />

Le problème et que l'aspect ne peut pas être appliqué à un document, il me revoit le message "Could not update aspect".

est ce que j'ai manqué qc?


Merci.
7 Replies
lamba
Active Member

Re: [Alfresco Share] Aspect personnalisé

D'abord, veuillez me confirmer si les étapes que j'ai entrepris pour ajouter mon aspect personnalisé sont correctes  :?:
Est ce que c'est la même démarche pour l'ajout d'un type de contenu personnalisé  :?:

Merci d'avance.
lamba
Active Member

Re: [Alfresco Share] Aspect personnalisé

SVP, ceux qui ont réussi à ajouter un nouveau aspect sous Share, veuillez m'aider  :cry:


Merci.
dgenard
Active Member

Re: [Alfresco Share] Aspect personnalisé

Bonjour,
la démarche m'a l'air correcte.
Pouvez-vous donner plus de détails sur le message d'erreur (stracktrace, …) ?

Denis
lamba
Active Member

Re: [Alfresco Share] Aspect personnalisé

Voilà ce qu'il me retourne

17:10:25,921 DEBUG [org.alfresco.web.scripts.servlet.WebScriptServlet] Processing request (GET) http://localhost:8080/share/service/modules/documentlibrary/aspects?htmlid=template_x002e_documentli...
17:10:25,921 DEBUG [org.alfresco.web.scripts.AbstractRuntime] (Runtime=ServletRuntime, Container=WebFramework) Processing script url (GET) /modules/documentlibrary/aspects
17:10:25,937 DEBUG [org.alfresco.web.scripts.DeclarativeRegistry] Web Script index lookup for uri /modules/documentlibrary/aspects took 0.198938ms
17:10:25,937 DEBUG [org.alfresco.web.scripts.servlet.WebScriptServletRequest] Content Type: null
17:10:25,937 DEBUG [org.alfresco.web.scripts.AbstractRuntime] Agent: Firefox
17:10:25,937 DEBUG [org.alfresco.web.scripts.AbstractRuntime] Invoking Web Script org/alfresco/modules/documentlibrary/aspects.get (format html, style: any, default: html)
17:10:25,937 DEBUG [org.alfresco.web.scripts.servlet.WebScriptServletResponse] Cache - set response header Cache-Control: no-cache
17:10:25,937 DEBUG [org.alfresco.web.scripts.servlet.WebScriptServletResponse] Cache - set response header Pragma: no-cache
17:10:25,937 DEBUG [org.alfresco.web.scripts.DeclarativeWebScript] Rendering response: content type=text/html, status=200
17:10:25,937 DEBUG [org.alfresco.web.scripts.DeclarativeWebScript] Rendering template 'org/alfresco/modules/documentlibrary/aspects.get.html.ftl'
17:10:25,937 DEBUG [org.alfresco.web.scripts.PresentationTemplateProcessor] Executing template: org/alfresco/modules/documentlibrary/aspects.get.html.ftl
17:10:25,937 DEBUG [org.alfresco.web.scripts.PresentationTemplateProcessor] Time to execute template: 0.577495ms
17:10:25,937 DEBUG [org.alfresco.web.scripts.AbstractWebScript] Rendered template org/alfresco/modules/documentlibrary/aspects.get.html.ftl in 1.034427ms
17:10:25,937 DEBUG [org.alfresco.web.scripts.AbstractRuntime] Web Script org/alfresco/modules/documentlibrary/aspects.get executed in 4.10338ms
17:10:25,937 DEBUG [org.alfresco.web.scripts.AbstractRuntime] Processed script url (GET) /modules/documentlibrary/aspects in 5.197181ms
17:10:26,062 DEBUG [org.alfresco.web.scripts.servlet.EndPointProxyServlet] EndPointProxyServlet preparing to proxy:
17:10:26,062 DEBUG [org.alfresco.web.scripts.servlet.EndPointProxyServlet]  - endpointId: alfresco
17:10:26,062 DEBUG [org.alfresco.web.scripts.servlet.EndPointProxyServlet]  - userId: admin
17:10:26,062 DEBUG [org.alfresco.web.scripts.servlet.EndPointProxyServlet]  - connector: http://localhost:8080/alfresco/s - {cleartextUsername=admin, cleartextPassword=admin}
17:10:26,062 DEBUG [org.alfresco.web.scripts.servlet.EndPointProxyServlet]  - method: GET
17:10:26,062 DEBUG [org.alfresco.web.scripts.servlet.EndPointProxyServlet]  - url: /slingshot/doclib/aspects/node/workspace/SpacesStore/a79a81fd-103e-461b-8cf7-2c0b312ba9ad
dgenard
Active Member

Re: [Alfresco Share] Aspect personnalisé

Je vois dans le premier post un problème de namespace.

Dans aspects.get.config.xml, vous devriez avoir plutôt quelque chose comme
<aspect name="{http://www.alfresco.com/model/knowledgebase/1.0}referencable" />

Denis
lamba
Active Member

Re: [Alfresco Share] Aspect personnalisé

Salut Denis,

J'ai effectué ce changement mais voilà ce qu'il me retourne:

{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "02120002 Wrapped Exception (with status template): 02120001 Error during processing of the template 'A namespace prefix is not registered for uri http:\/\/www.alfresco.org\/model\/knowledgebase\/1.0'. Please contact your system administrator.", 
  "exception" : "org.alfresco.web.scripts.WebScriptException - 02120002 Wrapped Exception (with status template): 02120001 Error during processing of the template 'A namespace prefix is not registered for uri http:\/\/www.alfresco.org\/model\/knowledgebase\/1.0'. Please contact your system administrator.",
 
  "callstack" :
  [
       ""      ,"org.alfresco.service.namespace.NamespaceException: A namespace prefix is not registered for uri http:\/\/www.alfresco.org\/model\/knowledgebase\/1.0"
      ,"org.alfresco.service.namespace.QName.toPrefixString(QName.java:407)"
      ,"org.alfresco.repo.template.ShortQNameMethod.exec(ShortQNameMethod.java:83)"
      ,"freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)"
      ,"freemarker.core.Expression.getAsTemplateModel(Expression.java:89)"
      ,"freemarker.core.ListLiteral.getModelList(ListLiteral.java:119)"
      ,"freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:89)"
      ,"freemarker.core.Expression.getAsTemplateModel(Expression.java:89)"
      ,"freemarker.core.Expression.getStringValue(Expression.java:93)"
      ,"freemarker.core.DollarVariable.accept(DollarVariable.java:76)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.MixedContent.accept(MixedContent.java:92)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)"
      ,"freemarker.core.Environment.visit(Environment.java:415)"
      ,"freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.MixedContent.accept(MixedContent.java:92)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.EscapeBlock.accept(EscapeBlock.java:84)"
      ,"freemarker.core.Environment.visit(Environment.java:208)"
      ,"freemarker.core.Environment.process(Environment.java:188)"
      ,"freemarker.template.Template.process(Template.java:237)"
      ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:202)"
      ,"org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:523)"
      ,"org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:241)"
      ,"org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:372)"
      ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:327)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:422)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:439)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:303)"
      ,"org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:306)"
      ,"org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:183)"
      ,"org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)"
      ,"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.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: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.Http11Processor.process(Http11Processor.java:845)"
      ,"org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)"
      ,"org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)"
      ,"java.lang.Thread.run(Thread.java:619)"
      ,"org.alfresco.service.cmr.repository.TemplateException: 02120001 Error during processing of the template 'A namespace prefix is not registered for uri http:\/\/www.alfresco.org\/model\/knowledgebase\/1.0'. Please contact your system administrator."
      ,"org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:206)"
      ,"org.alfresco.web.scripts.WebScriptException: 02120002 Wrapped Exception (with status template): 02120001 Error during processing of the template 'A namespace prefix is not registered for uri http:\/\/www.alfresco.org\/model\/knowledgebase\/1.0'. Please contact your system administrator."
      ,"org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)"

  ],
 
  "server" : "Alfresco Community v3.2.0 (r2 2440) schema 3,300",
  "time" : "Mar 12, 2010 5:08:49 PM"
}

Qu'est ce qu'il faut faire?


Merci.
cleseach
Active Member II

Re: [Alfresco Share] Aspect personnalisé

Bonjour,

Un point de vigilance a garder en tête lorsque l'on recopie les fichiers ".sample" pour créer ses propres fichiers : il faut veiller à ce que les beans définis n'entrent pas en conflit.
Je m'explique : dans votre fichier kb-model-context.xml vous définissez le bean id="extension.dictionaryBootstrap". Il faut bien veiller à ce que ce même id ne soit pas utilisé ailleurs.

Cordialement,
Charles Le Seac'h