AnsweredAssumed Answered

WCM XML Metadata Extraction

Question asked by alfdhar on Jul 1, 2010
Latest reply on Jul 7, 2010 by alfdhar
Hi All,
          I am new to alfresco WCM.I need help on WCM XML Metadata Extraction. I have followed one blog and created the same that they have mentioned.

Steps :

modified customModel.xml (\tomcat\shared\classes\alfresco\extension\):

<namespaces>
      <namespace uri="http://wwww.demo.com/model/1.0" prefix="my"/>
   </namespaces>

   <types>
   </types>

   <aspects>
      <aspect name="my:press_release">
         <title>Sample Aspect for WCM - Press Release</title>
         <properties>
            <property name="my:abstract">
               <type>d:text</type>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>true</tokenised>
               </index>
            </property>
            <property name="my:expiration_date">
               <type>d:datetime</type>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>false</tokenised>
               </index>
            </property>
            <property name="my:numtimes">
               <type>d:int</type>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>false</tokenised>
               </index>
            </property>
         </properties>
      </aspect>

   </aspects>

</model>


ToRegister a Model:
custom-model-context.xml:

<bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/customModel.xml</value>
            </list>
        </property>
    </bean>
         
for webclient:
web-client-config-custom.xml

  <config evaluator="aspect-name" condition="my:press_release">
      <property-sheet>
         <show-property name="my:abstract" />
         <show-property name="my:expiration_date" />
         <show-property name="my:numtimes" />
      </property-sheet>
   </config>

Metadata Extraction:

<bean id="extracter.xml.sample.AlfrescoCustomModelMetadataExtracter" class="org.alfresco.repo.content.metadata.xml.XPathMetadataExtracter" parent="baseMetadataExtracter" init-method="init" >
   <property name="supportedDateFormats">
      <list>
          <value>yyyy-MM-dd</value>
      </list>
   </property>
      <property name="mappingProperties">
         <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="properties">
               <props>
                  <prop key="namespace.prefix.my">http://wwww.demo.com/model/1.0</prop>
        <prop key="abstract">my:abstract</prop>
                  <prop key="expiration_date">my:expiration_date</prop>
        <prop key="numtimes">my:numtimes</prop>
               </props>
            </property>
         </bean>
      </property>
      <property name="xpathMappingProperties">
         <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="properties">
               <props>
           <prop key="namespace.prefix.pr">http://www.alfresco.org/alfresco/pr</prop>
           <prop key="abstract">/press_release/abstract</prop>
                     <prop key="expiration_date">/press_release/expiration_date</prop>
           <prop key="numtimes">/press_release/numtimes</prop>
             </props>
            </property>
         </bean>
      </property>
   </bean>  
  
   <!–
      This selector examines the XML documents, executing the given XPath statements until a
      match is made.
   –>
   <bean id="extracter.xml.sample.selector.XPathSelector" class="org.alfresco.repo.content.selector.XPathContentWorkerSelector" init-method="init">
      <property name="workers">
         <map>
       <entry key="/pr:press_release">
          <ref bean="extracter.xml.sample.AlfrescoCustomModelMetadataExtracter" />
       </entry>
         <entry key="/press_release">
          <ref bean="extracter.xml.sample.AlfrescoCustomModelMetadataExtracter" />
            </entry>
         </map>
      </property>
   </bean>
  
   <!–
      This is the face of the XML metadata extraction.  If passes the XML document to each of
      the selectors, until one of them gives back a MetadataExtracter (via the selectors),
      which is then used as normal to extract the values.
      Note the use of the AVM-specific registry.
      The overwrite policy of the embedded extracters has no effect.  It is only this extractor's
      policy that is used.
   –>
   <bean id="extracter.xml.sample.XMLMetadataExtracter" class="org.alfresco.repo.content.metadata.xml.XmlMetadataExtracter" parent="baseMetadataExtracter">
      <property name="registry">
         <ref bean="avmMetadataExtracterRegistry" />
      </property>
      <property name="overwritePolicy">
         <value>EAGER</value>
      </property>
      <property name="selectors">
         <list>
            <ref bean="extracter.xml.sample.selector.XPathSelector" />
         </list>
      </property>
   </bean>


My Xml file which will be inside Webproject(Company Home > Web Projects > Samplewebproject > xml >press_release.xml)

press_release.xml

  <?xml version="1.0" encoding="UTF-8" ?>
- <pr:press_release xmlns:alf="http://www.alfresco.org" xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:pr="http://www.alfresco.org/alfresco/pr" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <pr:title>press_release</pr:title>
  <pr:abstract>press_release</pr:abstract>
  <pr:location>press_release</pr:location>
  <pr:body><p>press_release</p></pr:body>
  <pr:include_media_contacts>true</pr:include_media_contacts>
  <pr:launch_date>2010-06-01</pr:launch_date>
  <pr:expiration_date>2010-06-01</pr:expiration_date>
  <pr:numtimes>1234</pr:numtimes>
  </pr:press_release>

and then i created a rule for xml mime type with Extract common metadata rule for WebProject space.


after doing every thing , i couldnt view the added properties when view details of the generated xml . and i am getting the Warning Error:
13:05:43,675 User:admin WARN  [alfresco.missingProperties] Failed to find property 'mimetype' for node: avm://wwwsamplewebproject–admin/-1;www;avm_webapps;ROOT;xml;press_release.xml


Log File:

11:51:47,778  DEBUG [content.metadata.AbstractMappingMetadataExtracter] Added mapping from expiration_date to [{http://wwww.demo.com/model/1.0}expiration_date]
11:51:47,784  DEBUG [content.metadata.AbstractMappingMetadataExtracter] Added mapping from numtimes to [{http://wwww.demo.com/model/1.0}numtimes]
11:51:47,789  DEBUG [content.metadata.AbstractMappingMetadataExtracter] Added mapping from abstract to [{http://wwww.demo.com/model/1.0}abstract]
11:51:47,818  DEBUG [metadata.xml.XPathMetadataExtracter] Added mapping from expiration_date to /press_release/expiration_date
11:51:47,823  DEBUG [metadata.xml.XPathMetadataExtracter] Added mapping from numtimes to /press_release/numtimes
11:51:47,832  DEBUG [metadata.xml.XPathMetadataExtracter] Added mapping from abstract to /press_release/abstract/text()
11:51:47,841  DEBUG [content.metadata.MetadataExtracterRegistry] Registering metadata extracter: org.alfresco.repo.content.metadata.xml.XPathMetadataExtracter@194a8ba
11:51:47,889  DEBUG [content.metadata.MetadataExtracterRegistry] Registering metadata extracter: org.alfresco.repo.content.metadata.xml.XmlMetadataExtracter@17cc01d


Please help on this issue its very urgent…

Thanks in Advance

Outcomes