"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/main/java/com/openkm/servlet/admin/CheckTextExtractionServlet.java" between
OpenKM-document-management-system-6.3.10.tar.gz and OpenKM-document-management-system-6.3.11.tar.gz

About: OpenKM (Knowledge Management) is a document management system that allows easy management of documents, users, roles and finding your enterprise documents and records. Community version (source code).

CheckTextExtractionServlet.java  (OpenKM-document-management-system-6.3.10):CheckTextExtractionServlet.java  (OpenKM-document-management-system-6.3.11)
skipping to change at line 24 skipping to change at line 24
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* <p> * <p>
* You should have received a copy of the GNU General Public License along * 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., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
package com.openkm.servlet.admin; package com.openkm.servlet.admin;
import com.openkm.api.OKMDocument; import java.io.IOException;
import com.openkm.api.OKMRepository; import java.io.InputStream;
import com.openkm.bean.Repository; import java.util.Iterator;
import com.openkm.core.*; import java.util.List;
import com.openkm.extractor.RegisteredExtractors;
import com.openkm.extractor.TextExtractor; import javax.servlet.ServletContext;
import com.openkm.util.PathUtils; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.servlet.ServletContext; import com.openkm.api.OKMDocument;
import javax.servlet.ServletException; import com.openkm.api.OKMRepository;
import javax.servlet.http.HttpServletRequest; import com.openkm.bean.Repository;
import javax.servlet.http.HttpServletResponse; import com.openkm.core.AccessDeniedException;
import java.io.IOException; import com.openkm.core.DatabaseException;
import java.io.InputStream; import com.openkm.core.LockException;
import java.util.Iterator; import com.openkm.core.MimeTypeConfig;
import java.util.List; import com.openkm.core.PathNotFoundException;
import com.openkm.core.RepositoryException;
import com.openkm.extractor.RegisteredExtractors;
import com.openkm.extractor.TextExtractor;
import com.openkm.util.PathUtils;
/** /**
* Mime type management servlet * Mime type management servlet
*/ */
public class CheckTextExtractionServlet extends BaseServlet { public class CheckTextExtractionServlet extends BaseServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger log = LoggerFactory.getLogger(CheckTextExtractionSe rvlet.class); private static Logger log = LoggerFactory.getLogger(CheckTextExtractionSe rvlet.class);
public void doGet(HttpServletRequest request, HttpServletResponse respons e) throws IOException, ServletException { public void doGet(HttpServletRequest request, HttpServletResponse respons e) throws IOException, ServletException {
log.debug("doGet({}, {})", request, response); log.debug("doGet({}, {})", request, response);
skipping to change at line 128 skipping to change at line 135
if (repoPath != null && !repoPath.isEmpty()) { if (repoPath != null && !repoPath.isEmpty()) {
String name = PathUtils.getName(repoPath) ; String name = PathUtils.getName(repoPath) ;
mimeType = MimeTypeConfig.mimeTypes.getCo ntentType(name.toLowerCase()); mimeType = MimeTypeConfig.mimeTypes.getCo ntentType(name.toLowerCase());
is = OKMDocument.getInstance().getContent (null, repoPath, false); is = OKMDocument.getInstance().getContent (null, repoPath, false);
} }
long begin = System.currentTimeMillis(); long begin = System.currentTimeMillis();
if (is != null) { if (is != null) {
if (!MimeTypeConfig.MIME_UNDEFINED.equals (mimeType)) { if (!MimeTypeConfig.MIME_UNDEFINED.equals (mimeType)) {
TextExtractor extClass = Register try {
edExtractors.getTextExtractor(mimeType); if (extractor != null &&
!extractor.isEmpty()) {
if (extClass != null) { TextExtractor ext
try { Class = (TextExtractor) Class.forName(extractor).newInstance();
extractor = extCl text = extClass.e
ass.getClass().getCanonicalName(); xtractText(is, mimeType, null);
text = Registered } else {
Extractors.getText(mimeType, null, is); TextExtractor ext
} catch (Exception e) { Class = RegisteredExtractors.getTextExtractor(mimeType);
error = e.getMess
age(); if (extClass != n
ull) {
extractor
= extClass.getClass().getCanonicalName();
text = Re
gisteredExtractors.getText(mimeType, null, is);
} else {
extractor
= "Undefined text extractor";
}
} }
} else { } catch (Exception e) {
extractor = "Undefined te error = e.getMessage();
xt extractor";
} }
} }
} }
ServletContext sc = getServletContext(); ServletContext sc = getServletContext();
sc.setAttribute("docUuid", docUuid); sc.setAttribute("docUuid", docUuid);
sc.setAttribute("repoPath", repoPath); sc.setAttribute("repoPath", repoPath);
sc.setAttribute("text", text); sc.setAttribute("text", text);
sc.setAttribute("time", System.currentTimeMillis( ) - begin); sc.setAttribute("time", System.currentTimeMillis( ) - begin);
sc.setAttribute("mimeType", mimeType); sc.setAttribute("mimeType", mimeType);
sc.setAttribute("error", error); sc.setAttribute("error", error);
sc.setAttribute("extractor", extractor); sc.setAttribute("extractor", extractor);
sc.getRequestDispatcher("/admin/check_text_extrac tion.jsp").forward(request, response); sc.getRequestDispatcher("/admin/check_text_extrac tion.jsp").forward(request, response);
} }
} catch (DatabaseException e) { } catch (DatabaseException | FileUploadException | PathNotFoundEx
sendErrorRedirect(request, response, e); ception | AccessDeniedException | RepositoryException | LockException e) {
} catch (FileUploadException e) {
sendErrorRedirect(request, response, e);
} catch (PathNotFoundException e) {
sendErrorRedirect(request, response, e);
} catch (AccessDeniedException e) {
sendErrorRedirect(request, response, e);
} catch (RepositoryException e) {
sendErrorRedirect(request, response, e); sendErrorRedirect(request, response, e);
} finally { } finally {
IOUtils.closeQuietly(is); IOUtils.closeQuietly(is);
} }
} }
} }
 End of changes. 5 change blocks. 
39 lines changed or deleted 47 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)