use of org.codelibs.fess.annotation.Secured in project fess by codelibs.
the class AdminLabeltypeAction method details.
// -----------------------------------------------------
// Details
// -------
@Execute
@Secured({ ROLE, ROLE + VIEW })
public HtmlResponse details(final int crudMode, final String id) {
verifyCrudMode(crudMode, CrudMode.DETAILS);
saveToken();
return asHtml(path_AdminLabeltype_AdminLabeltypeDetailsJsp).useForm(EditForm.class, op -> {
op.setup(form -> {
labelTypeService.getLabelType(id).ifPresent(entity -> {
copyBeanToBean(entity, form, copyOp -> {
copyOp.excludeNull();
copyOp.exclude(Constants.PERMISSIONS);
});
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
form.permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
form.crudMode = crudMode;
}).orElse(() -> {
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), this::asListHtml);
});
});
}).renderWith(data -> {
registerRoleTypeItems(data);
});
}
use of org.codelibs.fess.annotation.Secured in project fess by codelibs.
the class AdminLogAction method download.
@Execute
@Secured({ ROLE, ROLE + VIEW })
public ActionResponse download(final String id) {
final String filename = new String(Base64.getDecoder().decode(id), StandardCharsets.UTF_8).replace("..", "").replaceAll("\\s", "");
final String logFilePath = systemHelper.getLogFilePath();
if (StringUtil.isNotBlank(logFilePath) && isLogFilename(filename)) {
final Path path = Paths.get(logFilePath, filename);
return asStream(filename).contentTypeOctetStream().stream(out -> {
try (InputStream in = Files.newInputStream(path)) {
out.write(in);
}
});
}
throwValidationError(messages -> messages.addErrorsCouldNotFindLogFile(GLOBAL, filename), this::asIndexHtml);
// no-op
return redirect(getClass());
}
use of org.codelibs.fess.annotation.Secured in project fess by codelibs.
the class AdminFileconfigAction method edit.
@Execute
@Secured({ ROLE })
public HtmlResponse edit(final EditForm form) {
validate(form, messages -> {
}, this::asListHtml);
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
final String id = form.id;
fileConfigService.getFileConfig(id).ifPresent(entity -> {
copyBeanToBean(entity, form, copyOp -> {
copyOp.excludeNull();
copyOp.exclude(Constants.PERMISSIONS, Constants.VIRTUAL_HOSTS);
});
form.permissions = stream(entity.getPermissions()).get(stream -> stream.map(permissionHelper::decode).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
form.virtualHosts = stream(entity.getVirtualHosts()).get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.joining("\n")));
}).orElse(() -> throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), this::asListHtml));
saveToken();
if (form.crudMode.intValue() == CrudMode.EDIT) {
// back
form.crudMode = CrudMode.DETAILS;
return asDetailsHtml();
}
form.crudMode = CrudMode.EDIT;
return asEditHtml();
}
use of org.codelibs.fess.annotation.Secured in project fess by codelibs.
the class AdminPluginAction method delete.
@Execute
@Secured({ ROLE })
public HtmlResponse delete(final DeleteForm form) {
validate(form, messages -> {
}, () -> asHtml(path_AdminPlugin_AdminPluginJsp));
verifyToken(() -> asHtml(path_AdminPlugin_AdminPluginJsp));
final Artifact artifact = new Artifact(form.name, form.version, null);
deleteArtifact(artifact);
saveInfo(messages -> messages.addSuccessDeletePlugin(GLOBAL, artifact.getFileName()));
return redirect(getClass());
}
Aggregations