In this section, we will discuss the case study of UI for Advance Search in WCM. Here we will provide different criteria for search, such as choosing the web form of which we want to search the content and the facility to choose the path in the ROOT folder to search the content. For this we will use Lucene search so that it will search only in a Staging Sandbox.
This search example is for free text-based search and does not provide the capability to search the content based on its property. We will see the example of searching content based on the content property in the next section.
To implement this functionality:
browse-sandbox.jsp
page as:<div style="float:right;padding-right:20px;padding-top:3px"> <a:actionLink id="advance-search-image" value="Advance Search" image="/images/icons/search_icon.gif" showLink="false" showLink="false" action="advanceSearch" /> <a:actionLink id="advance-search-apply" value="Advance Search" showLink="false" action="advanceSearch" /> </div>
jsp/extension/wcm/search
folder for rendering the Search UI Page. faces-config-custom.xml
file. This bean is going to handle search parameter retrieval process for Advanced Search JSP.<managed-bean> <description> The bean that holds a state for the Advanced Search screen. </description> <managed-bean-name>CustomAdvancedSearchBean</managed-bean-name> <managed-bean-class>com.cignex.web.bean.wcm.CustomAdvancedSearchBean </managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>nodeService</property-name> <value>#{NodeService}</value> </managed-property> <managed-property> <property-name>searchService</property-name> <value>#{SearchService}</value> </managed-property> <managed-property> <property-name>serviceRegistry</property-name> <value>#{ServiceRegistry}</value> </managed-property> </managed-bean>
com.cignex.web.bean.wcm.CustomAdvancedSearchBean
and implement a method [public Search ()]
that will perform the search with the specified parameters. This class will also have corresponding fields for all search components. CustomAdvanceSearchBean
, with the specified package structure, which will actually perform the search in the repository.This will search in all of the sub-folders of ROOT in the current web project and will also search for all the web forms. The Reset All button will reset all search criteria. Search will return the search results with the filename and corresponding path. The following screenshot shows a snap of the search screen, which searches for the text Alfresco in the current web project's Staging Sandbox.
This will search the text in all the sub-folders of ROOT in the current web project and will also search in a specific, selected web form as shown in the following screenshot:
This will search the specified text in the particular selected folder within the web project. The Folder Tree component allows you to choose the folder in which you want to search the text. The following screenshot shows the Folder Tree component and the search result:
This will search the specified text in a particular folder selected with the help of the Folder Tree component and also search the content created using the specified web form. The Select WebForm combo box will fetch all web forms associated with the current web project:
The case study we discussed in the previous section was for the free text search with advanced search criteria in the WCM. In this section, we will discuss how we can perform the search based on the metadata of particular content. Alfresco provides some of the metadata extractors, which are responsible for extracting the metadata from the added or updated content at the server side. Alfresco has different extractors for handling different types of mimetypes for DM.
In this section, we will see how we can configure XML Metadata Extractor for WCM. We will take the example of news content, which we are creating with the help of a news web form.
wcm-xml-metadata-extracter-context.xml.sample
file available in the<alf_home>/tomcat/shared/classes/alfresco/extension
folder to wcm-xml-metadata-extracter-context.xml
. This file will have bean declaration for WCM Metadata extraction, as follows:<bean id="avmMetadataExtracterRegistry" class="org.alfresco.repo.content.metadata. MetadataExtracterRegistry" /> ... <property name="invokePolicies"> <value>true</value> </property> ... <property name="metadataExtracterRegistry"> <ref bean="avmMetadataExtracterRegistry" /> </property> ... </bean>
AVMNodeService
fires policies for content creation and update that are listened to by avmMetadataExtractors
, which is responsible for initiating the metadata extraction for content newly created or updated. XpathMetadataExtracter
, as follows:<property name="xpathMappingProperties"> <bean class="org.springframework.beans.factory.config. PropertiesFactoryBean"> <property name="location"> <value> classpath:alfresco/extension/News-Xpath-Mappings. properties </value> </property> </bean> </property>
Here, News-Xpath-Mappings.properties
stored in the alfresco/extension
folder will have mappings of XPath as follows:
# Name Space namespace.prefix.trn=http://www.alfrescobook.com/webforms # XPATH Mappings short_title=news/shortTitle/text() content_header=news/contentHeader/text() content_sub_header=news/contentSubHeader/text() news_date=news/newsDate/text()
<property name="mappingProperties"> <bean class="org.springframework.beans.factory.config. PropertiesFactoryBean"> <property name="location"> <value>classpath:alfresco/extension/Content-Model-Mappings. properties </value> </property> </bean> </property>
Content-Model-Mappings.properties
stored in the alfresco/extension
folder will have a mapping of properties of the content model as:namespace.prefix.cignex=http://www.cignex.com # Mappings short_title=shortTitle content_header=contentHeader content_sub_header=contentSubHeader news_date=newsDate
XMLMetadataExtractor
and configure bean for this as:<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>
<aspect name="cignex:news"> <title>Cignex News</title> <properties> <property name="cignex:shortTitle"> <title>Short Title</title> <type>d:text</type> <index enabled="true"/> </property> <property name="cignex:contentHeader"> <title>Content Header</title> <type>d:text</type> <index enabled="true"/> </property> <property name="cignex:contentSubHeader"> <title>Content Sub Header</title> <type>d:text</type> <index enabled="true"/> </property> <property name="cignex:newsDate"> <title>News Date</title> <type>d:date</type> <index enabled="true"/> </property> </properties> </aspect>
@cignex:shortTitle:"CignexNews",@cignex:contentHeader:"Cignex*"