Initialer commit

This commit is contained in:
2026-03-18 22:00:54 +01:00
commit 7adb3acc8d
426 changed files with 8484 additions and 0 deletions

12
framework/.classpath Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

22
framework/.project Normal file
View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>framework</name>
<comment></comment>
<projects/>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments/>
</buildCommand>
</buildSpec>
<linkedResources/>
<filteredResources/>
</projectDescription>

View File

@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1

View File

@@ -0,0 +1,13 @@
#
#Sat Apr 01 12:17:22 CEST 2023
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.source=17
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.sourceFile=generate

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="framework">
<property name="context-root" value="framework"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
</wb-module>
</project-modules>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="jst.java"/>
<fixed facet="jst.web"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="jst.java" version="17"/>
</faceted-project>

25
framework/build.gradle Normal file
View File

@@ -0,0 +1,25 @@
plugins {
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
compileOnly 'jakarta.platform:jakarta.jakartaee-web-api:9.0.0'
compileOnly 'jakarta.persistence:jakarta.persistence-api:3.1.0'
compileOnly 'jakarta.resource:jakarta.resource-api:2.1.0'
compileOnly 'org.jboss.ejb3:jboss-ejb3-ext-api:2.3.0.Final'
compileOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'
compileOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
}
tasks.named('test') {
useJUnitPlatform()
}

Binary file not shown.

View File

@@ -0,0 +1,2 @@
Manifest-Version: 1.0

View File

@@ -0,0 +1,68 @@
package de.oaa.xxx.framework;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.persistence.EntityManager;
public abstract class AbstractDAO<T extends XXXEntity> {
private Logger LOGGER = LoggerFactory.getLogger(getClass());
private Class<T> entityClass;
private EntityManager entityManager;
public AbstractDAO(Class<T> entityClass, EntityManager entityManager) {
this.entityClass = entityClass;
this.entityManager = entityManager;
}
public void update(T toUpdate) {
try {
getEntityManager().merge(toUpdate);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
public void persist(T toPersist) {
try {
LOGGER.info("Persisting Entity " + toPersist);
getEntityManager().persist(toPersist);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
public void remove(T toRemove) {
try {
getEntityManager().remove(toRemove);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
public T findById(Object id) {
try {
return getEntityManager().find(entityClass, id);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return null;
}
}
public List<T> list() {
try {
return getEntityManager().createQuery("select e from " + entityClass.getSimpleName() + " e", entityClass).getResultList();
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return Collections.emptyList();
}
}
protected EntityManager getEntityManager() {
return entityManager;
}
}

View File

@@ -0,0 +1,5 @@
package de.oaa.xxx.framework;
public interface XXXEntity {
}

View File

@@ -0,0 +1,10 @@
package de.oaa.xxx.framework.request;
public class NotAuthorizedException extends Exception {
private static final long serialVersionUID = 1L;
NotAuthorizedException(String text) {
super(text);
}
}

View File

@@ -0,0 +1,32 @@
package de.oaa.xxx.framework.request;
import java.net.URI;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status;
public class RequestChecker {
public static User checkRequest(HttpServletRequest request) throws NotAuthorizedException {
String token = request.getHeader("token");
if (token == null) {
throw new NotAuthorizedException("Kein Token im Header");
}
Client clientPost = ClientBuilder.newClient();
Response response =
clientPost.target("http://localhost:8080/user-service/login/")
.queryParam("token", token).request().build("POST").invoke();
if (response == null || Status.CREATED.getStatusCode() != response.getStatus()) {
throw new NotAuthorizedException("Token konnte nicht validiert werden.");
}
URI uri = response.getLocation();
clientPost.close();
Client clientGet = ClientBuilder.newClient();
User result = clientGet.target(uri).request().get(User.class);
clientGet.close();
return result;
}
}

View File

@@ -0,0 +1,43 @@
package de.oaa.xxx.framework.request;
import java.util.UUID;
public class User {
private UUID userId;
private String name;
private String email;
private String password;
public UUID getUserId() {
return userId;
}
public void setUserId(UUID userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}