All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.svws_nrw.api.RestAppSchemaRoot Maven / Gradle / Ivy

Go to download

Diese Bibliothek enthält die Java-Server-Definition der OpenApi-Schnittstelle für die Schulverwaltungssoftware in NRW

There is a newer version: 1.0.3
Show newest version
package de.svws_nrw.api;

import java.util.Set;

import de.svws_nrw.api.privileged.APIPrivilegedConfig;
import de.svws_nrw.api.privileged.APIPrivilegedSchema;
import jakarta.ws.rs.core.Application;


/**
 * Diese Applikation stellt die Rest-API für DB-Schema-Zugriffe bereit,
 * welche root-Rechte auf der Datenbank erfordern.
 */
public final class RestAppSchemaRoot extends Application {

	/** Die Pfad-Spezifikation für diese Applikation */
	private static final String[] pathSpec = { "/api/schema/root/*", "/api/schema/liste/*", "/api/schema/create/*", "/api/schema/export/*",
			"/api/schema/import/*", "/api/schema/migrate/*", "/api/schema/update/*", "/api/privileged/*", "/openapi/privileged.json",
			"/openapi/privileged.yaml" };

	/// Enthält die API-Klassen für diese Applikation
	private final Set> classes = Set.of(
			OpenAPICorsFilter.class,
			APIPrivilegedConfig.class,
			APIPrivilegedSchema.class,
			OpenApiSchemaRoot.class);

	@Override
	public Set> getClasses() {
		return classes;
	}

	/**
	 * Gibt die Pfad-Spezifikation für die App zurück
	 *
	 * @return die Pfad-Spezifikation
	 */
	public static String[] getPathSpecification() {
		return pathSpec;
	}

	/**
	 * Prüft, ob der übergebene Pfad in der Pfad-Spezifikation enthalten ist oder nicht
	 *
	 * @param path   der zu prüfende Pfad
	 *
	 * @return true, falls er enthalten ist
	 */
	public static boolean checkIsInPathSpecification(final String path) {
		if (path == null)
			return false;
		for (final String pathSpec : pathSpec)
			if (path.equals(pathSpec) || (pathSpec.endsWith("/*") && (path.equals(pathSpec.substring(0, pathSpec.length() - 2))))
					|| (pathSpec.endsWith("*") && (path.startsWith(pathSpec.substring(0, pathSpec.length() - 1)))))
				return true;
		return false;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy