11-04-2011 08:14 AM
11-05-2011 10:03 AM
public class DoNotIndexIntercempor implements MethodInterceptor {
private static Log logger = LogFactory.getLog(DoNotIndexIntercempor.class);
protected NodeService nodeService;
public Object invoke(MethodInvocation mi) throws Throwable {
NodeRef nodeRef;
QName propertyQName;
String contentUrl;
ContentData contentData = null;
// check if "getReader" is called
if (mi.getMethod().getName().equals("getReader")) {
// recuperate nodeRef
Object[] args = mi.getArguments();
if (args != null && (args[0] instanceof NodeRef)) {
nodeRef = (NodeRef) args[0];
if (this.nodeService.hasAspect(nodeRef,
NotIndexContent.ASPECT_NOT_INDEXED_CONTENT)) {
if (logger.isDebugEnabled() == true) {
logger.debug("Aspect ASPECT_NOT_INDEXED_CONTENT found");
}
if (args[1] instanceof QName) {
try {
// try to recuperate the read property name
propertyQName = (QName) args[1];
} catch (ClassCastException e) {
return mi.proceed();
}
// check if the call is on the content property
if (propertyQName.equals(ContentModel.PROP_CONTENT)) {
if (logger.isDebugEnabled() == true) {
logger.debug("PROP_CONTENT tested");
}
//get the content URL
Serializable propValue = nodeService.getProperty(nodeRef, propertyQName);
if (propValue != null && (propValue instanceof ContentData))
{
contentData = (ContentData)propValue;
contentUrl = contentData.getContentUrl();
// return empty stream
return new EmptyContentReader(contentUrl);
}
}
}
}
}
}
// Test done, then delegate
return mi.proceed();
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
}
11-07-2011 05:58 AM
Hola,
Vi por ahi un inteceptor de Spring que permitia cancelar la indexacion de contenido en documentos que tuviesen aplicado un determinado Aspect,
En Alfresco 4 ya se incluye esta funcionalidad por defecto y cuando le aplicas ese aspecto a un documento este no se indexa.public class DoNotIndexIntercempor implements MethodInterceptor {
private static Log logger = LogFactory.getLog(DoNotIndexIntercempor.class);
protected NodeService nodeService;
public Object invoke(MethodInvocation mi) throws Throwable {
NodeRef nodeRef;
QName propertyQName;
String contentUrl;
ContentData contentData = null;
// check if "getReader" is called
if (mi.getMethod().getName().equals("getReader")) {
// recuperate nodeRef
Object[] args = mi.getArguments();
if (args != null && (args[0] instanceof NodeRef)) {
nodeRef = (NodeRef) args[0];
if (this.nodeService.hasAspect(nodeRef,
NotIndexContent.ASPECT_NOT_INDEXED_CONTENT)) {
if (logger.isDebugEnabled() == true) {
logger.debug("Aspect ASPECT_NOT_INDEXED_CONTENT found");
}
if (args[1] instanceof QName) {
try {
// try to recuperate the read property name
propertyQName = (QName) args[1];
} catch (ClassCastException e) {
return mi.proceed();
}
// check if the call is on the content property
if (propertyQName.equals(ContentModel.PROP_CONTENT)) {
if (logger.isDebugEnabled() == true) {
logger.debug("PROP_CONTENT tested");
}
//get the content URL
Serializable propValue = nodeService.getProperty(nodeRef, propertyQName);
if (propValue != null && (propValue instanceof ContentData))
{
contentData = (ContentData)propValue;
contentUrl = contentData.getContentUrl();
// return empty stream
return new EmptyContentReader(contentUrl);
}
}
}
}
}
}
// Test done, then delegate
return mi.proceed();
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.