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;
}
}
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;
}
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.