protected OptionalEntity<FileConfig> getFileConfig(final CreateForm form) { final String username = systemHelper.getUsername(); final long currentTime = systemHelper.getCurrentTimeAsLong(); return getEntity(form, username, currentTime) .map( entity -> { entity.setUpdatedBy(username); entity.setUpdatedTime(currentTime); copyBeanToBean( form, entity, op -> op.exclude( Stream.concat( Stream.of(Constants.COMMON_CONVERSION_RULE), Stream.of(Constants.PERMISSIONS)) .toArray(n -> new String[n]))); final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper(); entity.setPermissions( split(form.permissions, "\n") .get( stream -> stream .map(s -> permissionHelper.encode(s)) .filter(StringUtil::isNotBlank) .distinct() .toArray(n -> new String[n]))); return entity; }); }
// ----------------------------------------------------- // Details // ------- @Execute public HtmlResponse details(final int crudMode, final String id) { verifyCrudMode(crudMode, CrudMode.DETAILS); saveToken(); return asHtml(path_AdminFileconfig_AdminFileconfigDetailsJsp) .useForm( EditForm.class, op -> op.setup( form -> { fileConfigService .getFileConfig(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), () -> asListHtml())); })) .renderWith(data -> registerRolesAndLabels(data)); }