Search in sources :

Example 36 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class PrunedTag method parse.

public static PrunedTag[] parse(final String value) {
    return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(v -> {
        final Pattern pattern = Pattern.compile("(\\w+)(\\[[^\\]]+\\])?(\\.[\\w\\-]+)?(#[\\w\\-]+)?");
        final Matcher matcher = pattern.matcher(v.trim());
        if (matcher.matches()) {
            final PrunedTag tag = new PrunedTag(matcher.group(1));
            if (matcher.group(2) != null) {
                final String attrPair = matcher.group(2).substring(1, matcher.group(2).length() - 1);
                final Matcher equalMatcher = Pattern.compile("([\\w\\-]+)=(\\S+)").matcher(attrPair);
                if (equalMatcher.matches()) {
                    tag.setAttr(equalMatcher.group(1), equalMatcher.group(2));
                }
            }
            if (matcher.group(3) != null) {
                tag.setCss(matcher.group(3).substring(1));
            }
            if (matcher.group(4) != null) {
                tag.setId(matcher.group(4).substring(1));
            }
            return tag;
        }
        throw new FessSystemException("Invalid pruned tag: " + v);
    }).toArray(n -> new PrunedTag[n]));
}
Also used : Objects(java.util.Objects) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) Matcher(java.util.regex.Matcher) StreamUtil(org.codelibs.core.stream.StreamUtil) FessSystemException(org.codelibs.fess.exception.FessSystemException) Node(org.w3c.dom.Node) StringUtil(org.codelibs.core.lang.StringUtil) Pattern(java.util.regex.Pattern) StringUtils(org.apache.commons.lang3.StringUtils) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) FessSystemException(org.codelibs.fess.exception.FessSystemException)

Example 37 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class ApiAdminElevatewordAction method get$setting.

// GET /api/admin/elevateword/{id}
@Execute
public JsonResponse<ApiResult> get$setting(final String id) {
    final ElevateWord entity = elevateWordService.getElevateWord(id).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
        return null;
    });
    final EditBody body = createEditBody(entity);
    final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
    body.permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
    return asJson(new ApiResult.ApiConfigResponse().setting(body).status(ApiResult.Status.OK).result());
}
Also used : Constants(org.codelibs.fess.Constants) FessSystemException(org.codelibs.fess.exception.FessSystemException) ElevateWordPager(org.codelibs.fess.app.pager.ElevateWordPager) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Status(org.codelibs.fess.app.web.api.ApiResult.Status) StreamResponse(org.lastaflute.web.response.StreamResponse) CrudMode(org.codelibs.fess.app.web.CrudMode) CommonPoolUtil(org.codelibs.core.concurrent.CommonPoolUtil) OutputStreamWriter(java.io.OutputStreamWriter) Path(java.nio.file.Path) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) ElevateWordService(org.codelibs.fess.app.service.ElevateWordService) Files(java.nio.file.Files) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) BufferedWriter(java.io.BufferedWriter) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) Reader(java.io.Reader) JsonResponse(org.lastaflute.web.response.JsonResponse) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) UploadForm(org.codelibs.fess.app.web.admin.elevateword.UploadForm) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) List(java.util.List) ComponentUtil(org.codelibs.fess.util.ComponentUtil) AdminElevatewordAction.getElevateWord(org.codelibs.fess.app.web.admin.elevateword.AdminElevatewordAction.getElevateWord) Writer(java.io.Writer) Execute(org.lastaflute.web.Execute) ElevateWord(org.codelibs.fess.es.config.exentity.ElevateWord) BufferedReader(java.io.BufferedReader) SuggestHelper(org.codelibs.fess.helper.SuggestHelper) InputStream(java.io.InputStream) AdminElevatewordAction.getElevateWord(org.codelibs.fess.app.web.admin.elevateword.AdminElevatewordAction.getElevateWord) ElevateWord(org.codelibs.fess.es.config.exentity.ElevateWord) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil) Execute(org.lastaflute.web.Execute)

Example 38 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class ApiAdminLabeltypeAction method createEditBody.

protected EditBody createEditBody(final LabelType entity) {
    final EditBody body = new EditBody();
    copyBeanToBean(entity, body, copyOp -> {
        copyOp.excludeNull();
        copyOp.exclude(Constants.PERMISSIONS);
    });
    final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
    body.permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
    return body;
}
Also used : AdminLabeltypeAction.getLabelType(org.codelibs.fess.app.web.admin.labeltype.AdminLabeltypeAction.getLabelType) Constants(org.codelibs.fess.Constants) LabelTypePager(org.codelibs.fess.app.pager.LabelTypePager) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) LabelType(org.codelibs.fess.es.config.exentity.LabelType) LabelTypeService(org.codelibs.fess.app.service.LabelTypeService) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) ComponentUtil(org.codelibs.fess.util.ComponentUtil) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil)

Example 39 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class CrawlJob method executeCrawler.

protected void executeCrawler() {
    final List<String> cmdList = new ArrayList<>();
    final String cpSeparator = SystemUtils.IS_OS_WINDOWS ? ";" : ":";
    final ServletContext servletContext = ComponentUtil.getComponent(ServletContext.class);
    final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
    final ProcessHelper processHelper = ComponentUtil.getProcessHelper();
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    cmdList.add(fessConfig.getJavaCommandPath());
    // -cp
    cmdList.add("-cp");
    final StringBuilder buf = new StringBuilder(100);
    ResourceUtil.getOverrideConfPath().ifPresent(p -> {
        buf.append(p);
        buf.append(cpSeparator);
    });
    final String confPath = System.getProperty(Constants.FESS_CONF_PATH);
    if (StringUtil.isNotBlank(confPath)) {
        buf.append(confPath);
        buf.append(cpSeparator);
    }
    // WEB-INF/env/crawler/resources
    buf.append("WEB-INF");
    buf.append(File.separator);
    buf.append("env");
    buf.append(File.separator);
    buf.append(getExecuteType());
    buf.append(File.separator);
    buf.append("resources");
    buf.append(cpSeparator);
    // WEB-INF/classes
    buf.append("WEB-INF");
    buf.append(File.separator);
    buf.append("classes");
    // target/classes
    final String userDir = System.getProperty("user.dir");
    final File targetDir = new File(userDir, "target");
    final File targetClassesDir = new File(targetDir, "classes");
    if (targetClassesDir.isDirectory()) {
        buf.append(cpSeparator);
        buf.append(targetClassesDir.getAbsolutePath());
    }
    // WEB-INF/lib
    appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/lib")), "WEB-INF" + File.separator + "lib" + File.separator);
    // WEB-INF/env/crawler/lib
    appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/env/" + getExecuteType() + "/lib")), "WEB-INF" + File.separator + "env" + File.separator + getExecuteType() + File.separator + "lib" + File.separator);
    // WEB-INF/plugin
    appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/plugin")), "WEB-INF" + File.separator + "plugin" + File.separator);
    final File targetLibDir = new File(targetDir, "fess" + File.separator + "WEB-INF" + File.separator + "lib");
    if (targetLibDir.isDirectory()) {
        appendJarFile(cpSeparator, buf, targetLibDir, targetLibDir.getAbsolutePath() + File.separator);
    }
    cmdList.add(buf.toString());
    if (useLocalFesen) {
        final String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
        if (StringUtil.isNotBlank(httpAddress)) {
            cmdList.add("-D" + Constants.FESS_ES_HTTP_ADDRESS + "=" + httpAddress);
        }
    }
    final String systemLastaEnv = System.getProperty("lasta.env");
    if (StringUtil.isNotBlank(systemLastaEnv)) {
        if ("web".equals(systemLastaEnv)) {
            cmdList.add("-Dlasta.env=" + getExecuteType());
        } else {
            cmdList.add("-Dlasta.env=" + systemLastaEnv);
        }
    } else if (StringUtil.isNotBlank(lastaEnv)) {
        cmdList.add("-Dlasta.env=" + lastaEnv);
    } else {
        cmdList.add("-Dlasta.env=" + getExecuteType());
    }
    addFessConfigProperties(cmdList);
    addFessSystemProperties(cmdList);
    addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
    cmdList.add("-Dfess." + getExecuteType() + ".process=true");
    cmdList.add("-Dfess.log.path=" + (logFilePath != null ? logFilePath : systemHelper.getLogFilePath()));
    addSystemProperty(cmdList, "fess.log.name", "fess-" + getExecuteType(), "-" + getExecuteType());
    if (logLevel == null) {
        addSystemProperty(cmdList, "fess.log.level", null, null);
    } else {
        cmdList.add("-Dfess.log.level=" + logLevel);
        if ("debug".equalsIgnoreCase(logLevel)) {
            cmdList.add("-Dorg.apache.tika.service.error.warn=true");
        }
    }
    stream(fessConfig.getJvmCrawlerOptionsAsArray()).of(stream -> stream.filter(StringUtil::isNotBlank).forEach(value -> cmdList.add(value)));
    File ownTmpDir = null;
    final String tmpDir = System.getProperty("java.io.tmpdir");
    if (fessConfig.isUseOwnTmpDir() && StringUtil.isNotBlank(tmpDir)) {
        ownTmpDir = new File(tmpDir, "fessTmpDir_" + sessionId);
        if (ownTmpDir.mkdirs()) {
            cmdList.add("-Djava.io.tmpdir=" + ownTmpDir.getAbsolutePath());
            cmdList.add("-Dpdfbox.fontcache=" + ownTmpDir.getAbsolutePath());
        } else {
            ownTmpDir = null;
        }
    }
    cmdList.add(ComponentUtil.getThumbnailManager().getThumbnailPathOption());
    if (!jvmOptions.isEmpty()) {
        jvmOptions.stream().filter(StringUtil::isNotBlank).forEach(cmdList::add);
    }
    cmdList.add(Crawler.class.getCanonicalName());
    cmdList.add("--sessionId");
    cmdList.add(sessionId);
    cmdList.add("--name");
    cmdList.add(namespace);
    if (webConfigIds != null && webConfigIds.length > 0) {
        cmdList.add("-w");
        cmdList.add(StringUtils.join(webConfigIds, ','));
    }
    if (fileConfigIds != null && fileConfigIds.length > 0) {
        cmdList.add("-f");
        cmdList.add(StringUtils.join(fileConfigIds, ','));
    }
    if (dataConfigIds != null && dataConfigIds.length > 0) {
        cmdList.add("-d");
        cmdList.add(StringUtils.join(dataConfigIds, ','));
    }
    if (documentExpires >= -1) {
        cmdList.add("-e");
        cmdList.add(Integer.toString(documentExpires));
    }
    final File propFile = ComponentUtil.getSystemHelper().createTempFile(getExecuteType() + "_", ".properties");
    try {
        cmdList.add("-p");
        cmdList.add(propFile.getAbsolutePath());
        createSystemProperties(cmdList, propFile);
        final File baseDir = new File(servletContext.getRealPath("/WEB-INF")).getParentFile();
        if (logger.isInfoEnabled()) {
            logger.info("Crawler: \nDirectory={}\nOptions={}", baseDir, cmdList);
        }
        final JobProcess jobProcess = processHelper.startProcess(sessionId, cmdList, pb -> {
            pb.directory(baseDir);
            pb.redirectErrorStream(true);
        });
        final InputStreamThread it = jobProcess.getInputStreamThread();
        it.start();
        final Process currentProcess = jobProcess.getProcess();
        currentProcess.waitFor();
        it.join(5000);
        final int exitValue = currentProcess.exitValue();
        if (logger.isInfoEnabled()) {
            logger.info("Crawler: Exit Code={} - Process Output:\n{}", exitValue, it.getOutput());
        }
        if (exitValue != 0) {
            final StringBuilder out = new StringBuilder();
            if (processTimeout) {
                out.append("Process is terminated due to ").append(timeout).append(" second exceeded.\n");
            }
            out.append("Exit Code: ").append(exitValue).append("\nOutput:\n").append(it.getOutput());
            throw new JobProcessingException(out.toString());
        }
    } catch (final JobProcessingException e) {
        throw e;
    } catch (final Exception e) {
        throw new JobProcessingException("Crawler Process terminated.", e);
    } finally {
        try {
            processHelper.destroyProcess(sessionId);
        } finally {
            if (propFile != null && !propFile.delete()) {
                logger.warn("Failed to delete {}.", propFile.getAbsolutePath());
            }
            deleteTempDir(ownTmpDir);
        }
    }
}
Also used : Constants(org.codelibs.fess.Constants) Date(java.util.Date) InputStreamThread(org.codelibs.fess.util.InputStreamThread) SimpleDateFormat(java.text.SimpleDateFormat) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) ResourceUtil(org.codelibs.fess.util.ResourceUtil) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ScheduledJobBhv(org.codelibs.fess.es.config.exbhv.ScheduledJobBhv) JobProcessingException(org.codelibs.fess.exception.JobProcessingException) JobProcess(org.codelibs.fess.util.JobProcess) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) ProcessHelper(org.codelibs.fess.helper.ProcessHelper) SystemUtils(org.apache.commons.lang3.SystemUtils) StringUtil(org.codelibs.core.lang.StringUtil) File(java.io.File) List(java.util.List) Logger(org.apache.logging.log4j.Logger) ComponentUtil(org.codelibs.fess.util.ComponentUtil) SystemHelper(org.codelibs.fess.helper.SystemHelper) Crawler(org.codelibs.fess.exec.Crawler) ServletContext(javax.servlet.ServletContext) TimeoutTask(org.codelibs.core.timer.TimeoutTask) LogManager(org.apache.logging.log4j.LogManager) ArrayList(java.util.ArrayList) JobProcess(org.codelibs.fess.util.JobProcess) Crawler(org.codelibs.fess.exec.Crawler) ProcessHelper(org.codelibs.fess.helper.ProcessHelper) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) JobProcess(org.codelibs.fess.util.JobProcess) JobProcessingException(org.codelibs.fess.exception.JobProcessingException) JobProcessingException(org.codelibs.fess.exception.JobProcessingException) InputStreamThread(org.codelibs.fess.util.InputStreamThread) SystemHelper(org.codelibs.fess.helper.SystemHelper) ServletContext(javax.servlet.ServletContext) StringUtil(org.codelibs.core.lang.StringUtil) File(java.io.File)

Example 40 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class GenerateThumbnailJob method executeThumbnailGenerator.

protected void executeThumbnailGenerator() {
    final List<String> cmdList = new ArrayList<>();
    final String cpSeparator = SystemUtils.IS_OS_WINDOWS ? ";" : ":";
    final ServletContext servletContext = ComponentUtil.getComponent(ServletContext.class);
    final ProcessHelper processHelper = ComponentUtil.getProcessHelper();
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    cmdList.add(fessConfig.getJavaCommandPath());
    // -cp
    cmdList.add("-cp");
    final StringBuilder buf = new StringBuilder(100);
    ResourceUtil.getOverrideConfPath().ifPresent(p -> {
        buf.append(p);
        buf.append(cpSeparator);
    });
    final String confPath = System.getProperty(Constants.FESS_CONF_PATH);
    if (StringUtil.isNotBlank(confPath)) {
        buf.append(confPath);
        buf.append(cpSeparator);
    }
    // WEB-INF/env/thumbnail/resources
    buf.append("WEB-INF");
    buf.append(File.separator);
    buf.append("env");
    buf.append(File.separator);
    buf.append(getExecuteType());
    buf.append(File.separator);
    buf.append("resources");
    buf.append(cpSeparator);
    // WEB-INF/classes
    buf.append("WEB-INF");
    buf.append(File.separator);
    buf.append("classes");
    // target/classes
    final String userDir = System.getProperty("user.dir");
    final File targetDir = new File(userDir, "target");
    final File targetClassesDir = new File(targetDir, "classes");
    if (targetClassesDir.isDirectory()) {
        buf.append(cpSeparator);
        buf.append(targetClassesDir.getAbsolutePath());
    }
    // WEB-INF/lib
    appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/lib")), "WEB-INF" + File.separator + "lib" + File.separator);
    // WEB-INF/env/thumbnail/lib
    appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/env/" + getExecuteType() + "/lib")), "WEB-INF" + File.separator + "env" + File.separator + getExecuteType() + File.separator + "lib" + File.separator);
    // WEB-INF/plugin
    appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/plugin")), "WEB-INF" + File.separator + "plugin" + File.separator);
    final File targetLibDir = new File(targetDir, "fess" + File.separator + "WEB-INF" + File.separator + "lib");
    if (targetLibDir.isDirectory()) {
        appendJarFile(cpSeparator, buf, targetLibDir, targetLibDir.getAbsolutePath() + File.separator);
    }
    cmdList.add(buf.toString());
    if (useLocalFesen) {
        final String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
        if (StringUtil.isNotBlank(httpAddress)) {
            cmdList.add("-D" + Constants.FESS_ES_HTTP_ADDRESS + "=" + httpAddress);
        }
    }
    final String systemLastaEnv = System.getProperty("lasta.env");
    if (StringUtil.isNotBlank(systemLastaEnv)) {
        if ("web".equals(systemLastaEnv)) {
            cmdList.add("-Dlasta.env=" + getExecuteType());
        } else {
            cmdList.add("-Dlasta.env=" + systemLastaEnv);
        }
    } else if (StringUtil.isNotBlank(lastaEnv)) {
        cmdList.add("-Dlasta.env=" + lastaEnv);
    } else {
        cmdList.add("-Dlasta.env=" + getExecuteType());
    }
    addFessConfigProperties(cmdList);
    addFessSystemProperties(cmdList);
    addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
    cmdList.add("-Dfess." + getExecuteType() + ".process=true");
    if (logFilePath == null) {
        final String value = System.getProperty("fess.log.path");
        logFilePath = value != null ? value : new File(targetDir, "logs").getAbsolutePath();
    }
    cmdList.add("-Dfess.log.path=" + logFilePath);
    addSystemProperty(cmdList, Constants.FESS_VAR_PATH, null, null);
    addSystemProperty(cmdList, Constants.FESS_THUMBNAIL_PATH, null, null);
    addSystemProperty(cmdList, "fess.log.name", "fess-" + getExecuteType(), "-" + getExecuteType());
    if (logLevel != null) {
        cmdList.add("-Dfess.log.level=" + logLevel);
    }
    stream(fessConfig.getJvmThumbnailOptionsAsArray()).of(stream -> stream.filter(StringUtil::isNotBlank).forEach(value -> cmdList.add(value)));
    File ownTmpDir = null;
    final String tmpDir = System.getProperty("java.io.tmpdir");
    if (fessConfig.isUseOwnTmpDir() && StringUtil.isNotBlank(tmpDir)) {
        ownTmpDir = new File(tmpDir, "fessTmpDir_" + sessionId);
        if (ownTmpDir.mkdirs()) {
            cmdList.add("-Djava.io.tmpdir=" + ownTmpDir.getAbsolutePath());
        } else {
            ownTmpDir = null;
        }
    }
    if (!jvmOptions.isEmpty()) {
        jvmOptions.stream().filter(StringUtil::isNotBlank).forEach(cmdList::add);
    }
    cmdList.add(ThumbnailGenerator.class.getCanonicalName());
    cmdList.add("--sessionId");
    cmdList.add(sessionId);
    cmdList.add("--numOfThreads");
    cmdList.add(Integer.toString(numOfThreads));
    if (cleanup) {
        cmdList.add("--cleanup");
    }
    final File propFile = ComponentUtil.getSystemHelper().createTempFile(getExecuteType() + "_", ".properties");
    try {
        cmdList.add("-p");
        cmdList.add(propFile.getAbsolutePath());
        createSystemProperties(cmdList, propFile);
        final File baseDir = new File(servletContext.getRealPath("/WEB-INF")).getParentFile();
        if (logger.isInfoEnabled()) {
            logger.info("ThumbnailGenerator: \nDirectory={}\nOptions={}", baseDir, cmdList);
        }
        final JobProcess jobProcess = processHelper.startProcess(sessionId, cmdList, pb -> {
            pb.directory(baseDir);
            pb.redirectErrorStream(true);
        });
        final InputStreamThread it = jobProcess.getInputStreamThread();
        it.start();
        final Process currentProcess = jobProcess.getProcess();
        currentProcess.waitFor();
        it.join(5000);
        final int exitValue = currentProcess.exitValue();
        if (logger.isInfoEnabled()) {
            logger.info("ThumbnailGenerator: Exit Code={} - Process Output:\n{}", exitValue, it.getOutput());
        }
        if (exitValue != 0) {
            final StringBuilder out = new StringBuilder();
            if (processTimeout) {
                out.append("Process is terminated due to ").append(timeout).append(" second exceeded.\n");
            }
            out.append("Exit Code: ").append(exitValue).append("\nOutput:\n").append(it.getOutput());
            throw new JobProcessingException(out.toString());
        }
        ComponentUtil.getPopularWordHelper().clearCache();
    } catch (final JobProcessingException e) {
        throw e;
    } catch (final Exception e) {
        throw new JobProcessingException("ThumbnailGenerator Process terminated.", e);
    } finally {
        try {
            processHelper.destroyProcess(sessionId);
        } finally {
            if (propFile != null && !propFile.delete()) {
                logger.warn("Failed to delete {}.", propFile.getAbsolutePath());
            }
            deleteTempDir(ownTmpDir);
        }
    }
}
Also used : Constants(org.codelibs.fess.Constants) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) ProcessHelper(org.codelibs.fess.helper.ProcessHelper) ThumbnailGenerator(org.codelibs.fess.exec.ThumbnailGenerator) SystemUtils(org.apache.commons.lang3.SystemUtils) InputStreamThread(org.codelibs.fess.util.InputStreamThread) StringUtil(org.codelibs.core.lang.StringUtil) File(java.io.File) ArrayList(java.util.ArrayList) ResourceUtil(org.codelibs.fess.util.ResourceUtil) List(java.util.List) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) Logger(org.apache.logging.log4j.Logger) ComponentUtil(org.codelibs.fess.util.ComponentUtil) ServletContext(javax.servlet.ServletContext) RandomStringUtils(org.apache.commons.lang3.RandomStringUtils) JobProcessingException(org.codelibs.fess.exception.JobProcessingException) TimeoutTask(org.codelibs.core.timer.TimeoutTask) LogManager(org.apache.logging.log4j.LogManager) JobProcess(org.codelibs.fess.util.JobProcess) ArrayList(java.util.ArrayList) JobProcess(org.codelibs.fess.util.JobProcess) ProcessHelper(org.codelibs.fess.helper.ProcessHelper) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) JobProcess(org.codelibs.fess.util.JobProcess) JobProcessingException(org.codelibs.fess.exception.JobProcessingException) JobProcessingException(org.codelibs.fess.exception.JobProcessingException) InputStreamThread(org.codelibs.fess.util.InputStreamThread) ThumbnailGenerator(org.codelibs.fess.exec.ThumbnailGenerator) ServletContext(javax.servlet.ServletContext) StringUtil(org.codelibs.core.lang.StringUtil) File(java.io.File)

Aggregations

StringUtil (org.codelibs.core.lang.StringUtil)46 ComponentUtil (org.codelibs.fess.util.ComponentUtil)41 Constants (org.codelibs.fess.Constants)40 StreamUtil.stream (org.codelibs.core.stream.StreamUtil.stream)38 Collectors (java.util.stream.Collectors)35 List (java.util.List)30 StreamUtil.split (org.codelibs.core.stream.StreamUtil.split)27 PermissionHelper (org.codelibs.fess.helper.PermissionHelper)26 ArrayList (java.util.ArrayList)25 Resource (javax.annotation.Resource)20 CrudMode (org.codelibs.fess.app.web.CrudMode)19 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)19 OptionalThing (org.dbflute.optional.OptionalThing)19 Execute (org.lastaflute.web.Execute)19 Map (java.util.Map)17 Stream (java.util.stream.Stream)17 SystemHelper (org.codelibs.fess.helper.SystemHelper)17 OptionalEntity (org.dbflute.optional.OptionalEntity)17 LogManager (org.apache.logging.log4j.LogManager)16 Logger (org.apache.logging.log4j.Logger)16