use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class ChangeProjectAccessLevelAction method fetchCurrentProjectAccessLevel.
private ProjectAccessLevel fetchCurrentProjectAccessLevel(String projectId, DeveloperAdministration administration) {
DeveloperProjectDetailInformation details = administration.fetchProjectDetailInformation(projectId);
ProjectAccessLevel currentAccesslevel = ProjectAccessLevel.fromId(details.getAccessLevel());
return currentAccesslevel;
}
use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class ChangeProjectAccessLevelAction method execute.
@Override
public void execute(ActionEvent e) {
Optional<String> optProjectId = getUserInput("Please enter project ID/name", InputCacheIdentifier.PROJECT_ID);
if (!optProjectId.isPresent()) {
return;
}
String projectId = optProjectId.get().toLowerCase().trim();
DeveloperAdministration administration = getContext().getAdministration();
ProjectAccessLevel currentAccessLevel = fetchCurrentProjectAccessLevel(projectId, administration);
ChangeProjectAccessLevelDialogUI dialogUI = new ChangeProjectAccessLevelDialogUI(getContext(), projectId, currentAccessLevel);
dialogUI.showDialog();
if (!dialogUI.isOkPressed()) {
return;
}
ProjectAccessLevel wantedAccessLevel = dialogUI.getSelectedValue();
if (!confirm("Do you really want to change the project access level for project:" + projectId + " to " + wantedAccessLevel + " ?")) {
return;
}
administration.changeProjectAccessLevel(projectId, wantedAccessLevel);
}
use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class SchedulerProjectConfigService method getProjectAccessLevelOrFallback.
private ProjectAccessLevel getProjectAccessLevelOrFallback(String projectId, ProjectAccessLevel fallback) {
ProjectAccessLevel defaultValue = fallback;
if (defaultValue == null) {
defaultValue = DEFAULT_ACCESS_LEVEL;
LOG.warn("Given project access level fallback was null - should not happen. Used instead now default :{}", defaultValue.getId());
}
ProjectAccessLevel configuredAccessLevel = getOrCreateConfig(projectId).getProjectAccessLevel();
return configuredAccessLevel;
}
use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class SchedulerProjectConfigServiceTest method fetchProjectAccessLevel_returns_result_from_scanProjectConfigService_by_getOrCreate.
@Test
void fetchProjectAccessLevel_returns_result_from_scanProjectConfigService_by_getOrCreate() {
/* prepare */
SchedulerProjectConfig config = new SchedulerProjectConfig();
config.projectId = PROJECT1;
config.projectAccessLevel = null;
when(repository.findById(PROJECT1)).thenReturn(Optional.of(config));
/* part 1: test */
ProjectAccessLevel result = serviceToTest.getProjectAccessLevel(PROJECT1);
/* test */
assertNull(result);
/* part 2: for each level we try out as well */
for (ProjectAccessLevel level : ProjectAccessLevel.values()) {
/* execute */
config.projectAccessLevel = level;
result = serviceToTest.getProjectAccessLevel(PROJECT1);
/* test */
assertEquals(level, result);
}
}
use of com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel in project sechub by mercedes-benz.
the class ScheduleMessageHandler method handleProcessAccessLevelChanged.
@IsReceivingAsyncMessage(MessageID.PROJECT_ACCESS_LEVEL_CHANGED)
@UseCaseAdministratorChangesProjectAccessLevel(@Step(number = 4, name = "Event handler", description = "Receives change project access level event"))
private void handleProcessAccessLevelChanged(DomainMessage request) {
ProjectMessage data = request.get(MessageDataKeys.PROJECT_ACCESS_LEVEL_CHANGE_DATA);
String projectId = data.getProjectId();
ProjectAccessLevel formerAccessLevel = data.getFormerAccessLevel();
ProjectAccessLevel newAccessLevel = data.getNewAccessLevel();
projectConfigService.changeProjectAccessLevel(projectId, newAccessLevel, formerAccessLevel);
}
Aggregations