Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/403-entfernung-von-unnötigen-lee…
Browse files Browse the repository at this point in the history
…rzeilen-zu-beginn-einer-methode' into 403-entfernung-von-unnötigen-leerzeilen-zu-beginn-einer-methode

# Conflicts:
#	wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/urnenwahlschliessungsuhrzeit/UrnenwahlSchliessungsUhrzeitWriteDTO.java
  • Loading branch information
dragonfly28 committed Sep 23, 2024
2 parents 5c18a40 + 0f2068d commit 3d1207d
Show file tree
Hide file tree
Showing 61 changed files with 1,608 additions and 55 deletions.
6 changes: 5 additions & 1 deletion docs/src/features/vorfaelleundvorkommnisse-service/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ Der Service hat keine Abhängigkeiten zu anderen Services.
## Daten und Funktionen

- Verwalten und Übermitteln von Vorfällen und Vorkommnissen
- Laden und Anzeigen besonderer Ereignisse
- Laden und Anzeigen besonderer Ereignisse

## Fachliches Datenmodell

![Image of Ereignisse data model](/vorfaelleundvorkommnisse/fachliches_datenmodell_ereignisse.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
id: add authorities vorfaelleundvorkommnisse
author: vjohnslhm
realm: ${SSO_REALM}
changes:
- addRole:
name: VorfaelleUndVorkommnisse_BUSINESSACTION_GetEreignisse
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allVorfaelleUndVorkommnisseAuthorities
role: VorfaelleUndVorkommnisse_BUSINESSACTION_GetEreignisse
clientId: ${SSO_CLIENT_ID}

- addRole:
name: VorfaelleUndVorkommnisse_BUSINESSACTION_PostEreignisse
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allVorfaelleUndVorkommnisseAuthorities
role: VorfaelleUndVorkommnisse_BUSINESSACTION_PostEreignisse
clientId: ${SSO_CLIENT_ID}

- addRole:
name: VorfaelleUndVorkommnisse_READ_Ereignisse
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allVorfaelleUndVorkommnisseAuthorities
role: VorfaelleUndVorkommnisse_READ_Ereignisse
clientId: ${SSO_CLIENT_ID}

- addRole:
name: VorfaelleUndVorkommnisse_WRITE_Ereignisse
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allVorfaelleUndVorkommnisseAuthorities
role: VorfaelleUndVorkommnisse_WRITE_Ereignisse
clientId: ${SSO_CLIENT_ID}

- addRole:
name: VorfaelleUndVorkommnisse_DELETE_Ereignisse
clientRole: true
clientId: ${SSO_CLIENT_ID}
- assignRoleToGroup:
group: allVorfaelleUndVorkommnisseAuthorities
role: VorfaelleUndVorkommnisse_DELETE_Ereignisse
clientId: ${SSO_CLIENT_ID}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
id: create group allVorfaelleUndVorkommnisseAuthorities and link wls_all*
author: vjohnslhm
realm: ${SSO_REALM}
changes:
- addGroup:
name: allVorfaelleUndVorkommnisseAuthorities
- assignGroup:
user: wls_all
group: allVorfaelleUndVorkommnisseAuthorities
- assignGroup:
user: wls_all_uwb
group: allVorfaelleUndVorkommnisseAuthorities
- assignGroup:
user: wls_all_bwb
group: allVorfaelleUndVorkommnisseAuthorities
2 changes: 2 additions & 0 deletions stack/keycloak/migration/keycloak-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ includes:
- path: add-authorities-basisdaten-wahlen.yml
- path: add-authorities-basisdaten-kopfdaten.yml
- path: add-authorities-basisdaten-wahlbezirke.yml
- path: create-group-all-vorfaelleundvorkommnisse-authorities.yml
- path: add-authorities-vorfaelleundvorkommnisse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void postWahlen(final WahlenWriteModel wahlenWriteModel) {
wahlRepository.saveAll(wahlModelMapper.fromListOfWahlModeltoListOfWahlEntities(wahlenWriteModel.wahlen()));
} catch (Exception e) {
log.error("#postWahlen: Die Wahlen konnten aufgrund eines Fehlers nicht gespeichert werden:", e);
throw exceptionFactory.createFachlicheWlsException(ExceptionConstants.POSTWAHLEN_UNSAVEABLE);
throw exceptionFactory.createTechnischeWlsException(ExceptionConstants.POSTWAHLEN_UNSAVEABLE);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ void accessDeniedWhenServiceAuthorityIsMissing() {
}

@Test
void fachlicheWlsExceptionWhenRepoAuthorityIsMissing() {
void technischeWlsExceptionWhenRepoAuthorityIsMissing() {
SecurityUtils.runWith(Authorities.SERVICE_POST_WAHLEN);
val wahltagID = "wahltagID";
List<WahlModel> mockedListOfModels = createWahlModels();
val wahlenToWrite = new WahlenWriteModel(wahltagID, mockedListOfModels);

Assertions.assertThatThrownBy(() -> wahlenService.postWahlen(wahlenToWrite)).isInstanceOf(
FachlicheWlsException.class);
TechnischeWlsException.class);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel;
import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageService;
import de.muenchen.oss.wahllokalsystem.wls.common.exception.FachlicheWlsException;
import de.muenchen.oss.wahllokalsystem.wls.common.exception.TechnischeWlsException;
import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionFactory;
import java.time.LocalDate;
import java.util.ArrayList;
Expand Down Expand Up @@ -116,11 +116,11 @@ void wlsExceptionWhenSavingFailed() {
val wahlenToWrite = new WahlenWriteModel(wahltagID, mockedListOfModels);

val mockedRepoSaveException = new RuntimeException("saving failed");
val mockedWlsException = FachlicheWlsException.withCode("").buildWithMessage("");
val mockedWlsException = TechnischeWlsException.withCode("").buildWithMessage("");

Mockito.when(wahlModelMapper.fromListOfWahlModeltoListOfWahlEntities(mockedListOfModels)).thenReturn(mockedListOfEntities);
Mockito.doThrow(mockedRepoSaveException).when(wahlRepository).saveAll(mockedListOfEntities);
Mockito.when(exceptionFactory.createFachlicheWlsException(ExceptionConstants.POSTWAHLEN_UNSAVEABLE))
Mockito.when(exceptionFactory.createTechnischeWlsException(ExceptionConstants.POSTWAHLEN_UNSAVEABLE))
.thenReturn(mockedWlsException);

Assertions.assertThatThrownBy(() -> unitUnderTest.postWahlen(wahlenToWrite)).isSameAs(mockedWlsException);
Expand Down
36 changes: 34 additions & 2 deletions wls-vorfaelleundvorkommnisse-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
<!-- Version muss mit der in den spring-boot-dependencies bereitgestellten Lombok-Version übereinstimmen -->
<org.projectlombok.lombok.version>1.18.30</org.projectlombok.lombok.version>
<org.projectlombok.mapstructbinding.version>0.2.0</org.projectlombok.mapstructbinding.version>
<org.mapstruct.version>1.6.0</org.mapstruct.version>
<org.springdoc.version>2.6.0</org.springdoc.version>
<wls.common.version>1.1.0</wls.common.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -105,6 +107,13 @@
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>

<!-- wls-common -->
<dependency>
<groupId>de.muenchen.oss.wahllokalsystem.wls-common</groupId>
<artifactId>security</artifactId>
<version>${wls.common.version}</version>
</dependency>

<!-- json etc. -->
<dependency>
<groupId>org.springframework.hateoas</groupId>
Expand Down Expand Up @@ -197,6 +206,12 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.muenchen.oss.wahllokalsystem.wls-common</groupId>
<artifactId>testing</artifactId>
<version>${wls.common.version}</version>
<scope>test</scope>
</dependency>

<!-- Logging -->
<dependency>
Expand Down Expand Up @@ -263,17 +278,21 @@
<optional>true</optional>
</dependency>

<!-- Mapping -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
</dependencies>


<scm>
<url>https://github.com/it-at-m/Wahllokalsystem</url>
<connection>scm:git:https://github.com/it-at-m/Wahllokalsystem.git</connection>
<developerConnection>scm:git:https://github.com/it-at-m/Wahllokalsystem.git</developerConnection>
<tag>HEAD</tag>
</scm>


<build>
<resources>
<resource>
Expand Down Expand Up @@ -328,12 +347,25 @@
<artifactId>lombok</artifactId>
<version>${org.projectlombok.lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>${org.projectlombok.mapstructbinding.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>
-Amapstruct.defaultComponentModel=spring
</compilerArg>
<compilerArg>
-Amapstruct.unmappedTargetPolicy=ERROR
</compilerArg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion wls-vorfaelleundvorkommnisse-service/runLocal.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mvn clean spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=local"
mvn clean spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=local, dummy.nobezirkid.check"
2 changes: 1 addition & 1 deletion wls-vorfaelleundvorkommnisse-service/runLocal.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
mvn clean spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=local"
mvn clean spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=local, dummy.nobezirkid.check"
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,13 @@
package de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

/**
* Application class for starting the micro-service.
*/
@Configuration
@ComponentScan(
basePackages = {
"org.springframework.data.jpa.convert.threeten",
"de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice"
}
)
@EntityScan(
basePackages = {
"org.springframework.data.jpa.convert.threeten",
Expand All @@ -32,7 +23,14 @@
"de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice"
}
)
@EnableAutoConfiguration
@SpringBootApplication(
scanBasePackages = {
"org.springframework.data.jpa.convert.threeten",
"de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice",
"de.muenchen.oss.wahllokalsystem.wls.common.exception",
"de.muenchen.oss.wahllokalsystem.wls.common.security"
}
)
public class MicroServiceApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ GroupedOpenApi publicApi() {
OpenAPI customOpenAPI() {
return new OpenAPI()
.info(
new Info().title("Auth Service")
new Info().title("Vorfälle und Vorkommnisse Service")
.version(version)
.contact(new Contact().name("Your Name").email("Your E-Mail-Address")))
.addSecurityItem(new SecurityRequirement().addList("bearerAuth"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice.domain.ereignis;

import de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice.domain.BaseEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class Ereignis extends BaseEntity {

@NotNull
@Size(max = 1024)
private String wahlbezirkID;

@Size(max = 1024)
private String beschreibung;

private LocalDateTime uhrzeit;

@Enumerated(EnumType.STRING)
@NotNull
private Ereignisart ereignisart;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice.domain.ereignis;

import java.util.List;
import java.util.UUID;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;

@PreAuthorize("hasAuthority('VorfaelleUndVorkommnisse_READ_Ereignisse')")
public interface EreignisRepository extends CrudRepository<Ereignis, UUID> {

String CACHE = "EreignisCACHE";

@Override
Iterable<Ereignis> findAll();

@Cacheable(value = CACHE, key = "#p0")
List<Ereignis> findByWahlbezirkID(String wahlbezirkID);

@Override
@CachePut(value = CACHE, key = "#p0.wahlbezirkID")
@PreAuthorize("hasAuthority('VorfaelleUndVorkommnisse_WRITE_Ereignisse')")
<S extends Ereignis> S save(S ereignis);

@Override
@CachePut(value = CACHE, key = "#p0.wahlbezirkID")
@PreAuthorize("hasAuthority('VorfaelleUndVorkommnisse_WRITE_Ereignisse')")
<S extends Ereignis> Iterable<S> saveAll(Iterable<S> iterable);

@Override
@CacheEvict(value = CACHE, key = "#p0")
@PreAuthorize("hasAuthority('VorfaelleUndVorkommnisse_DELETE_Ereignisse')")
void deleteById(UUID id);

@Override
@CacheEvict(value = CACHE, key = "#p0.wahlbezirkID")
@PreAuthorize("hasAuthority('VorfaelleUndVorkommnisse_DELETE_Ereignisse')")
void delete(Ereignis entity);

@Override
@CacheEvict(value = CACHE, allEntries = true)
@PreAuthorize("hasAuthority('VorfaelleUndVorkommnisse_DELETE_Ereignisse')")
void deleteAll(Iterable<? extends Ereignis> entities);

@Override
@CacheEvict(value = CACHE, allEntries = true)
@PreAuthorize("hasAuthority('VorfaelleUndVorkommnisse_DELETE_Ereignisse')")
void deleteAll();

@CacheEvict(value = CACHE, allEntries = true)
@PreAuthorize("hasAuthority('VorfaelleUndVorkommnisse_DELETE_Ereignisse')")
@Transactional
void deleteByWahlbezirkID(String wahlbezirkID);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice.domain.ereignis;

public enum Ereignisart {
VORFALL, VORKOMMNIS
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.muenchen.oss.wahllokalsystem.vorfaelleundvorkommnisseservice.exception;

import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionDataWrapper;

public class ExceptionConstants {

public static final ExceptionDataWrapper GETEREIGNIS_SUCHKRITERIEN_UNVOLLSTAENDIG = new ExceptionDataWrapper("100",
"Fehler in getEreignis(): Suchkriterien unvollständig.");
public static final ExceptionDataWrapper POSTEREIGNIS_PARAMS_UNVOLLSTAENDIG = new ExceptionDataWrapper("102",
"Fehler in postEreignis(): Parameter unvollständig.");
public static final ExceptionDataWrapper SAVEEREIGNIS_UNSAVABLE = new ExceptionDataWrapper("103",
"Fehler in postEreignis(): Ereignis konnte nicht gespeichert werden.");
}
Loading

0 comments on commit 3d1207d

Please sign in to comment.