Search in sources :

Example 1 with InContextRedirectMav

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());
}
Also used : InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) TableSampleKey(io.datarouter.nodewatch.storage.tablesample.TableSampleKey) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 2 with InContextRedirectMav

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);
}
Also used : PhysicalSortedStorageReaderNode(io.datarouter.storage.node.op.raw.read.SortedStorageReader.PhysicalSortedStorageReaderNode) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 3 with InContextRedirectMav

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));
}
Also used : MessageMav(io.datarouter.web.handler.mav.imp.MessageMav) DatarouterUser(io.datarouter.web.user.databean.DatarouterUser) DatarouterPermissionRequest(io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) Date(java.util.Date) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 4 with InContextRedirectMav

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());
}
Also used : LatestTableCountKey(io.datarouter.nodewatch.storage.latesttablecount.LatestTableCountKey) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) TableCountKey(io.datarouter.nodewatch.storage.tablecount.TableCountKey) LatestTableCountKey(io.datarouter.nodewatch.storage.latesttablecount.LatestTableCountKey) TableSampleKey(io.datarouter.nodewatch.storage.tablesample.TableSampleKey) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 5 with InContextRedirectMav

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);
}
Also used : Role(io.datarouter.web.user.session.service.Role) DatarouterUser(io.datarouter.web.user.databean.DatarouterUser) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) BaseHandler(io.datarouter.web.handler.BaseHandler)

Aggregations

BaseHandler (io.datarouter.web.handler.BaseHandler)7 InContextRedirectMav (io.datarouter.web.handler.mav.imp.InContextRedirectMav)7 DatarouterChangelogDtoBuilder (io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)3 DatarouterUser (io.datarouter.web.user.databean.DatarouterUser)3 TableSampleKey (io.datarouter.nodewatch.storage.tablesample.TableSampleKey)2 MessageMav (io.datarouter.web.handler.mav.imp.MessageMav)2 OptionalString (io.datarouter.web.handler.types.optional.OptionalString)2 DatarouterPermissionRequest (io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest)1 LatestTableCountKey (io.datarouter.nodewatch.storage.latesttablecount.LatestTableCountKey)1 TableCountKey (io.datarouter.nodewatch.storage.tablecount.TableCountKey)1 ClientId (io.datarouter.storage.client.ClientId)1 PhysicalSortedStorageReaderNode (io.datarouter.storage.node.op.raw.read.SortedStorageReader.PhysicalSortedStorageReaderNode)1 GlobalRedirectMav (io.datarouter.web.handler.mav.imp.GlobalRedirectMav)1 Role (io.datarouter.web.user.session.service.Role)1 Date (java.util.Date)1