Search in sources :

Example 1 with ProjectAccessLevel

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;
}
Also used : DeveloperProjectDetailInformation(com.mercedesbenz.sechub.developertools.admin.DeveloperProjectDetailInformation) ProjectAccessLevel(com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel)

Example 2 with ProjectAccessLevel

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);
}
Also used : DeveloperAdministration(com.mercedesbenz.sechub.developertools.admin.DeveloperAdministration) ProjectAccessLevel(com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel)

Example 3 with ProjectAccessLevel

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;
}
Also used : ProjectAccessLevel(com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel)

Example 4 with ProjectAccessLevel

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);
    }
}
Also used : ProjectAccessLevel(com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel) Test(org.junit.jupiter.api.Test)

Example 5 with ProjectAccessLevel

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);
}
Also used : ProjectMessage(com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage) ProjectAccessLevel(com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel) UseCaseAdministratorChangesProjectAccessLevel(com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdministratorChangesProjectAccessLevel) UseCaseAdministratorChangesProjectAccessLevel(com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdministratorChangesProjectAccessLevel) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Aggregations

ProjectAccessLevel (com.mercedesbenz.sechub.sharedkernel.project.ProjectAccessLevel)15 UseCaseAdministratorChangesProjectAccessLevel (com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdministratorChangesProjectAccessLevel)4 ProjectMessage (com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage)3 Test (org.junit.jupiter.api.Test)3 IsReceivingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)2 DeveloperAdministration (com.mercedesbenz.sechub.developertools.admin.DeveloperAdministration)1 DeveloperProjectDetailInformation (com.mercedesbenz.sechub.developertools.admin.DeveloperProjectDetailInformation)1 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)1 UseCaseRestDoc (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc)1 Test (org.junit.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1