cancel
Showing results for 
Search instead for 
Did you mean: 

Cómo desactivar lucene para archivos excel?

jmqsetting
Champ in-the-making
Champ in-the-making
¿Es posible evitar la indexación para archivos de un determinado tipo? (en mi caso excel).
Sí he visto en cambio, que se puede desactivar lucene por completo mediante parámetros de configuración.

  Se agradece la ayuda de antemano!

P.D:La versió que estoy utilizando es la Comunity 3.4.d
2 REPLIES 2

antoniosoler
Champ in-the-making
Champ in-the-making
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;

       }
}

jmqsetting
Champ in-the-making
Champ in-the-making
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;

       }
}

Muchas gracias por la respuesta!

  Aplicaré la solución y te comento…

Un saludo!