use of io.datarouter.web.handler.mav.imp.InContextRedirectMav in project datarouter by hotpads.
the class TableCountHandler method deleteRowSamples.
@Handler
private Mav deleteRowSamples(String clientName, String tableName) {
// delete rows from TableSample
var tableSampleKeyPrefix = new TableSampleKey(clientName, tableName, null, null);
tableSampleDao.deleteWithPrefix(tableSampleKeyPrefix);
var dto = new DatarouterChangelogDtoBuilder("Nodewatch", clientName + "." + tableName, "deleted row samples", getSessionInfo().getNonEmptyUsernameOrElse("")).build();
changelogRecorder.record(dto);
return new InContextRedirectMav(request, paths.datarouter.nodewatch.tableCount.toSlashedString());
}
use of io.datarouter.web.handler.mav.imp.InContextRedirectMav in project datarouter by hotpads.
the class TableCountHandler method resample.
@Handler
private Mav resample(String clientName, String tableName) {
var node = (PhysicalSortedStorageReaderNode<?, ?, ?>) nodes.getPhysicalNodeForClientAndTable(clientName, tableName);
tableSpanSamplerJobletCreatorFactory.create(node, tableSamplerService.getSampleInterval(node), tableSamplerService.getBatchSize(node), true, true, System.currentTimeMillis()).createJoblets();
var dto = new DatarouterChangelogDtoBuilder("Nodewatch", clientName + "." + tableName, "resample", getSessionInfo().getNonEmptyUsernameOrElse("")).build();
changelogRecorder.record(dto);
return new InContextRedirectMav(request, paths.datarouter.nodewatch.tableCount.toSlashedString() + "?submitAction=singleTable&clientName=" + clientName + "&tableName=" + tableName);
}
use of io.datarouter.web.handler.mav.imp.InContextRedirectMav in project datarouter by hotpads.
the class DatarouterPermissionRequestHandler method submit.
@Handler
private Mav submit(OptionalString specifics) {
if (!authenticationConfig.useDatarouterAuthentication()) {
return new MessageMav(noDatarouterAuthentication());
}
String reason = params.required(P_REASON);
if (StringTool.isEmpty(reason)) {
throw new IllegalArgumentException("Reason is required.");
}
String specificString = specifics.orElse("");
DatarouterUser user = getCurrentUser();
datarouterPermissionRequestDao.createPermissionRequest(new DatarouterPermissionRequest(user.getId(), new Date(), "reason: " + reason + ", specifics: " + specificString, null, null));
sendRequestEmail(user, reason, specificString);
// not just requestor, so send them to the home page after they make their request
if (user.getRoles().size() > 1) {
return new InContextRedirectMav(request, paths.home);
}
return showForm(new OptionalString(null), new OptionalString(null));
}
use of io.datarouter.web.handler.mav.imp.InContextRedirectMav in project datarouter by hotpads.
the class TableCountHandler method deleteAllMetadata.
@Handler
private Mav deleteAllMetadata(String clientName, String tableName) {
// delete rows from TableCount
var tableCountKeyPrefix = new TableCountKey(clientName, tableName, null);
tableCountDao.deleteWithPrefix(tableCountKeyPrefix);
// delete rows from TableSample
var tableSampleKeyPrefix = new TableSampleKey(clientName, tableName, null, null);
tableSampleDao.deleteWithPrefix(tableSampleKeyPrefix);
// delete from LatestTableCount
var latestTableCountKey = new LatestTableCountKey(clientName, tableName);
latestTableCountDao.delete(latestTableCountKey);
var dto = new DatarouterChangelogDtoBuilder("Nodewatch", clientName + "." + tableName, "deleted metadata", getSessionInfo().getNonEmptyUsernameOrElse("")).build();
changelogRecorder.record(dto);
return new InContextRedirectMav(request, paths.datarouter.nodewatch.tableCount.toSlashedString());
}
use of io.datarouter.web.handler.mav.imp.InContextRedirectMav in project datarouter by hotpads.
the class AdminEditUserHandler method createUserSubmit.
// TODO DATAROUTER-2786
@Handler
private Mav createUserSubmit() {
if (serverTypeDetector.mightBeProduction()) {
return pageFactory.message(request, "This is not supported on production");
}
DatarouterUser currentUser = getCurrentUser();
if (!roleManager.isAdmin(currentUser.getRoles())) {
handleInvalidRequest();
}
String username = params.required(authenticationConfig.getUsernameParam());
String password = params.required(authenticationConfig.getPasswordParam());
String[] roleStrings = params.optionalArray(authenticationConfig.getUserRolesParam()).orElse(EmptyArray.STRING);
Set<Role> requestedRoles = Arrays.stream(roleStrings).map(roleManager::getRoleFromPersistentString).collect(Collectors.toSet());
boolean enabled = params.optionalBoolean(authenticationConfig.getEnabledParam(), true);
datarouterUserCreationService.createManualUser(currentUser, username, password, requestedRoles, enabled, Optional.empty(), Optional.empty());
return new InContextRedirectMav(request, paths.admin.viewUsers);
}
Aggregations