Enabled metadata extraction in WCM.

A set of extracters for different mimetypes can be activated across AVM land.
The XML extraction sample has been modified to be AVM-specific, and therefore
includes the necessary config to activate the metadata extraction in AVM.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6238 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley 2007-07-13 00:33:55 +00:00
parent 82841201e2
commit 44f6b94cff
2 changed files with 159 additions and 7 deletions

View File

@ -2,17 +2,66 @@
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!--
Sample configuration of a XmlMetadataExtracters.
Sample configuration of a XmlMetadataExtracter in use within the WCM environment.
This show how XML metadata extraction can be set up to extract metadata from different
formats of XML.
formats of XML. It also shows how metadata can be extracted in WCM projects.
Since: 2.1
Author: Derek Hulley
-->
<beans>
<!-- An extractor that operates on Alfresco Model XML -->
<!--
In order to limit the number of extractors active for Web Content Management, a separate registry
must be created for the extractors.
-->
<bean id="avmMetadataExtracterRegistry" class="org.alfresco.repo.content.metadata.MetadataExtracterRegistry" />
<!--
Configure the AVM services to broadcast the content update notifications.
-->
<bean id="avmNodeService" class="org.alfresco.repo.avm.AVMNodeService" init-method="init">
<property name="dictionaryService">
<ref bean="dictionaryService"/>
</property>
<property name="avmService">
<ref bean="avmLockingAwareService"/>
</property>
<property name="policyComponent">
<ref bean="policyComponent"/>
</property>
<property name="invokePolicies">
<value>true</value>
</property>
</bean>
<bean id="avmMetadataExtracter" class="org.alfresco.repo.avm.AvmMetadataExtracter" init-method="init">
<property name="policyComponent">
<ref bean="policyComponent"/>
</property>
<property name="extracterAction">
<bean class="org.alfresco.repo.action.executer.ContentMetadataExtracter" >
<property name="dictionaryService">
<ref bean="dictionaryService"/>
</property>
<property name="nodeService">
<ref bean="avmNodeService" />
</property>
<property name="contentService">
<ref bean="contentService" />
</property>
<property name="metadataExtracterRegistry">
<ref bean="avmMetadataExtracterRegistry" />
</property>
</bean>
</property>
</bean>
<!--
Configure an extractor that targets Alfresco Model XML files.
Although this inherits from the base extracter bean, the use of the 'init' method
means that it isn't automatically registered.
-->
<bean id="extracter.xml.sample.AlfrescoModelMetadataExtracter"
class="org.alfresco.repo.content.metadata.xml.XPathMetadataExtracter"
parent="baseMetadataExtracter"
@ -54,7 +103,7 @@
<!--
This selector examines the XML documents, executing the given XPath statements until a
result is found.
match is made.
-->
<bean
id="extracter.xml.sample.selector.XPathSelector"
@ -74,14 +123,19 @@
<!--
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, which is then used as
normal to extract the values. The overwrite policy of the embedded extracters has no
effect. It is only this extracter's policy that is used.
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>

View File

@ -0,0 +1,98 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.avm;
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
/**
* A component that listens for changes to the content
*
* @since 2.1
* @author Derek Hulley
*/
public class AvmMetadataExtracter
implements ContentServicePolicies.OnContentUpdatePolicy
{
/** the component to register the behaviour with */
private PolicyComponent policyComponent;
/** the action that will do the work */
private ContentMetadataExtracter extracterAction;
/**
* @param policyComponent used for registrations
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* @param extracterAction the action that will perform the actual extraction
*/
public void setExtracterAction(ContentMetadataExtracter extracterAction)
{
this.extracterAction = extracterAction;
}
/**
* Registers the policy behaviour methods
*/
public void init()
{
policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate"),
this,
new JavaBehaviour(this, "onContentUpdate"));
}
/**
* When the content changes, the metadata is extracted.
*/
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
{
/*
* The use of the action here is a supreme hack. The code within the action is
* what we are after and it would be a shame to duplicate it. Also, it is the
* intention that rules will eventually work against AVM, making this class
* obsolete.
*/
// Ignore everything non-AVM
if (!nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{
return;
}
// We extract the content whether it is new or not
extracterAction.executeImpl(null, nodeRef);
}
}