File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
logicaldoc-core/src/main/java/com/logicaldoc/core/automation Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 3131import com .logicaldoc .core .metadata .Template ;
3232import com .logicaldoc .core .metadata .TemplateDAO ;
3333import com .logicaldoc .core .parser .ParsingException ;
34+ import com .logicaldoc .core .searchengine .Hit ;
35+ import com .logicaldoc .core .searchengine .SearchEngine ;
3436import com .logicaldoc .core .security .Tenant ;
3537import com .logicaldoc .core .security .TenantDAO ;
3638import com .logicaldoc .core .security .authorization .PermissionException ;
@@ -986,4 +988,27 @@ public String parse(Document document, String fileVersion) {
986988 return null ;
987989 }
988990 }
991+
992+ /**
993+ * Same as {@link #DocTool.parse()} but first it tries to get the text from
994+ * the already built fulltext index
995+ *
996+ * @param document The document to elaborate
997+ *
998+ * @return the extracted texts
999+ */
1000+ public String getText (Document document ) {
1001+ String text = null ;
1002+
1003+ if (document .getIndexed () == AbstractDocument .INDEX_INDEXED ) {
1004+ SearchEngine indexer = Context .get (SearchEngine .class );
1005+ Hit hit = indexer .getHit (document .getId ());
1006+ if (hit != null )
1007+ text = hit .getContent ();
1008+ }
1009+
1010+ if (StringUtils .isEmpty (text ))
1011+ text = parse (document , null );
1012+ return text ;
1013+ }
9891014}
You can’t perform that action at this time.
0 commit comments