use of org.lastaflute.web.Execute in project fess by codelibs.
the class AdminBackupAction method upload.
@Execute
public HtmlResponse upload(final UploadForm form) {
validate(form, messages -> {
}, () -> asListHtml());
verifyToken(() -> asListHtml());
asyncManager.async(() -> {
final String fileName = form.bulkFile.getFileName();
if (fileName.startsWith("system") && fileName.endsWith(".properties")) {
try (final InputStream in = form.bulkFile.getInputStream()) {
ComponentUtil.getSystemProperties().load(in);
} catch (final IOException e) {
logger.warn("Failed to process system.properties file: " + form.bulkFile.getFileName(), e);
}
} else {
try (CurlResponse response = Curl.post(ResourceUtil.getElasticsearchHttpUrl() + "/_bulk").header("Content-Type", "application/json").onConnect((req, con) -> {
con.setDoOutput(true);
try (InputStream in = form.bulkFile.getInputStream();
OutputStream out = con.getOutputStream()) {
CopyUtil.copy(in, out);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}).execute()) {
if (logger.isDebugEnabled()) {
logger.debug("Bulk Response:\n" + response.getContentAsString());
}
systemHelper.reloadConfiguration();
} catch (final Exception e) {
logger.warn("Failed to process bulk file: " + form.bulkFile.getFileName(), e);
}
}
});
saveInfo(messages -> messages.addSuccessBulkProcessStarted(GLOBAL));
// no-op
return redirect(getClass());
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class AdminDictProtwordsAction method download.
@Execute
public ActionResponse download(final DownloadForm form) {
validate(form, messages -> {
}, () -> downloadpage(form.dictId));
verifyTokenKeep(() -> downloadpage(form.dictId));
return protwordsService.getProtwordsFile(form.dictId).map(file -> {
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
try (InputStream inputStream = file.getInputStream()) {
out.write(inputStream);
}
});
}).orElseGet(() -> {
throwValidationError(messages -> messages.addErrorsFailedToDownloadProtwordsFile(GLOBAL), () -> downloadpage(form.dictId));
return null;
});
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class AdminDictSeunjeonAction method download.
@Execute
public ActionResponse download(final DownloadForm form) {
validate(form, messages -> {
}, () -> downloadpage(form.dictId));
verifyTokenKeep(() -> downloadpage(form.dictId));
return seunjeonService.getSeunjeonFile(form.dictId).map(file -> {
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
try (InputStream inputStream = file.getInputStream()) {
out.write(inputStream);
}
});
}).orElseGet(() -> {
throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL), () -> downloadpage(form.dictId));
return null;
});
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class AdminDictSynonymAction method download.
@Execute
public ActionResponse download(final DownloadForm form) {
validate(form, messages -> {
}, () -> downloadpage(form.dictId));
verifyTokenKeep(() -> downloadpage(form.dictId));
return synonymService.getSynonymFile(form.dictId).map(file -> {
return asStream(new File(file.getPath()).getName()).contentTypeOctetStream().stream(out -> {
try (InputStream inputStream = file.getInputStream()) {
out.write(inputStream);
}
});
}).orElseGet(() -> {
throwValidationError(messages -> messages.addErrorsFailedToDownloadSynonymFile(GLOBAL), () -> downloadpage(form.dictId));
return null;
});
}
use of org.lastaflute.web.Execute in project fess by codelibs.
the class AdminSearchlistAction method delete.
// -----------------------------------------------------
// Confirm
// -------
@Execute
public HtmlResponse delete(final DeleteForm form) {
validate(form, messages -> {
}, () -> asListHtml());
verifyToken(() -> asListHtml());
final String docId = form.docId;
try {
final QueryBuilder query = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), docId);
fessEsClient.deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(), fessConfig.getIndexDocumentType(), query);
saveInfo(messages -> messages.addSuccessDeleteDocFromIndex(GLOBAL));
} catch (final Exception e) {
throwValidationError(messages -> messages.addErrorsFailedToDeleteDocInAdmin(GLOBAL), () -> asListHtml());
}
return asListHtml();
}
Aggregations