Update src/main/java/org/openautonomousconnection/webserver/api/WebPage.java

This commit is contained in:
2026-03-02 16:32:42 +00:00
parent 14e2af25d6
commit 1a7a4617be

View File

@@ -1,25 +1,59 @@
# Open Autonomous Connection WebServer
package org.openautonomousconnection.webserver.api;
This is the WebServer for our Open Autonomous Connection project.<br />
Feel free to join our Discord.
<br />
import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
import org.openautonomousconnection.webserver.Main;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.html.HTMLBodyElement;
import org.w3c.dom.html.HTMLDocument;
import org.w3c.dom.html.HTMLHeadElement;
## License Notice
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
This project (OAC) is licensed under
the [Open Autonomous Public License (OAPL)](https://open-autonomous-connection.org/license.html).
/**
* Server-side Java page (v1.0.1-BETA).
*
* <p>Every .java page must extend this class.</p>
*/
public abstract class WebPage {
**Third-party components:**
<br />
Download all license here: https://open-autonomous-connection.org/assets/licenses.zip
- *UnlegitLibrary* is authored by the same copyright holder and is used here under a special agreement:
While [UnlegitLibrary](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/) is generally distributed under
the [GNU GPLv3](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/src/branch/master/LICENSE),
it is additionally licensed under OAPL **exclusively for the OAC project**.
Therefore, within OAC, the OAPL terms apply to UnlegitLibrary as well.
private static final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
# Bugs/Problems
private static final DocumentBuilder documentBuilder;
# In progress
static {
DocumentBuilder temp = null;
try {
temp = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
Main.getValues().logger.exception("Failed to create document builder", e);
temp = null;
}
# TODO
documentBuilder = temp;
}
protected final Document document;
protected final HTMLHeadElement head;
protected final HTMLBodyElement body;
/**
* Default constructor that creates a new Document instance
*/
public WebPage() {
this.document = documentBuilder.newDocument();
this.head = (HTMLHeadElement) this.document.createElement("head");
this.body = (HTMLBodyElement) this.document.createElement("body");
}
/**
* Handles a web request.
*
* @param ctx context (client, request, session)
* @return resource response packet
* @throws Exception on unexpected failures
*/
public abstract WebResourceResponsePacket handle(WebPageContext ctx) throws Exception;
}