use of com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException in project sechub by mercedes-benz.
the class SchedulerUploadService method assertJobFoundAndStillInitializing.
private void assertJobFoundAndStillInitializing(String projectId, UUID jobUUID) {
ScheduleSecHubJob secHubJob = assertService.assertJob(projectId, jobUUID);
ExecutionState state = secHubJob.getExecutionState();
if (!ExecutionState.INITIALIZING.equals(state)) {
// upload only possible when in initializing state
throw new NotAcceptableException("Not in correct state");
}
}
use of com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException in project sechub by mercedes-benz.
the class UserRepositoryImpl method deleteUserWithAssociations.
@Override
public void deleteUserWithAssociations(String userId) {
int count = countAmountOfOwnedProjects(userId);
if (count > 0) {
throw new NotAcceptableException("User " + userId + " is " + count + " times still owner of a project! Move ownership before delete!");
}
Query deleteProjectToUser = em.createNativeQuery(QUERY_DELETE_PROJECT_TO_USER);
deleteProjectToUser.setParameter(1, userId);
deleteProjectToUser.executeUpdate();
Query deleteUser = em.createNativeQuery(QUERY_DELETE_USER);
deleteUser.setParameter(1, userId);
deleteUser.executeUpdate();
}
use of com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException in project sechub by mercedes-benz.
the class UserDeleteService method deleteUser.
/* @formatter:off */
@Validated
@UseCaseAdminDeletesUser(@Step(number = 2, name = "Service deletes user.", next = { 3, 4 }, description = "The service will delete the user with dependencies and triggers asynchronous events"))
/* @formatter:on */
@Transactional
public void deleteUser(String userId) {
auditLogService.log("Triggers delete of user {}", logSanitizer.sanitize(userId, 30));
assertion.assertIsValidUserId(userId);
if (userId.contentEquals(userContext.getUserId())) {
throw new NotAcceptableException("You are not allowed to delete yourself!");
}
User user = userRepository.findOrFailUser(userId);
/* create message containing data before user is deleted */
UserMessage message = new UserMessage();
message.setUserId(user.getName());
message.setEmailAdress(user.getEmailAdress());
userRepository.deleteUserWithAssociations(user.getName());
informUserDeleted(message);
}
use of com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException in project sechub by mercedes-benz.
the class SchedulerSourcecodeUploadService method assertJobFoundAndStillInitializing.
private void assertJobFoundAndStillInitializing(String projectId, UUID jobUUID) {
ScheduleSecHubJob secHubJob = assertService.assertJob(projectId, jobUUID);
ExecutionState state = secHubJob.getExecutionState();
if (!ExecutionState.INITIALIZING.equals(state)) {
// upload only possible when in initializing state
throw new NotAcceptableException("Not in correct state");
}
}
use of com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException in project sechub by mercedes-benz.
the class SchedulerApproveJobService method approveJob.
@UseCaseUserApprovesJob(@Step(number = 2, name = "Try to find job annd update execution state", description = "When job is found and user has access job will be marked as ready for execution"))
public void approveJob(String projectId, UUID jobUUID) {
assertion.assertIsValidProjectId(projectId);
assertion.assertIsValidJobUUID(jobUUID);
assertService.assertUserHasAccessToProject(projectId);
assertService.assertProjectAllowsWriteAccess(projectId);
ScheduleSecHubJob secHubJob = assertService.assertJob(projectId, jobUUID);
ExecutionState state = secHubJob.getExecutionState();
if (!ExecutionState.INITIALIZING.equals(state)) {
throw new NotAcceptableException("Not in correct state");
}
secHubJob.setExecutionState(ExecutionState.READY_TO_START);
jobRepository.save(secHubJob);
LOG.info("job {} now approved", jobUUID);
}
Aggregations