Removed InfoName Class

This commit is contained in:
Finn
2025-12-11 08:59:28 +01:00
parent aea850193b
commit ecd973a88e
3 changed files with 8 additions and 73 deletions

View File

@@ -36,27 +36,20 @@ public class Classic_Domain implements Serializable {
* The destination of the domain, typically the full URL or address. * The destination of the domain, typically the full URL or address.
*/ */
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3") @Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
private final String destination; public final String destination;
/** /**
* The ProtocolBridge reference. * The ProtocolBridge reference.
*/ */
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3") @Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
private final ProtocolBridge protocolBridge; public final ProtocolBridge protocolBridge;
/**
* The encapsulated Domain object for modern usage.
*/
@Getter
private final InfoName infoName;
public Classic_Domain(String name, String topLevelDomain, String destination, String path, ProtocolBridge bridge) { public Classic_Domain(String name, String topLevelDomain, String destination, String path, ProtocolBridge bridge) {
this.protocolBridge = bridge; this.protocolBridge = bridge;
this.infoName = new InfoName(name + "." + topLevelDomain + "/" + (path.startsWith("/") ? path : "/" + path)); this.name = name;
this.name = infoName.getName(); this.topLevelDomain = topLevelDomain;
this.topLevelDomain = infoName.getTopLevelName(); this.destination = destination;
this.destination = infoName.getDestination(bridge); this.path = path;
this.path = infoName.getPath();
} }
@Override @Override

View File

@@ -1,58 +0,0 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
/**
* Utility class for converting between Classic protocol objects and new protocol objects.
*/
public final class ClassicConverter {
/**
* Converts a Classic_Domain object to a InfoName object.
*
* @param classicDomain the Classic_Domain object to convert
* @return the converted InfoName object
*/
@SuppressWarnings(value = "deprecation")
public static InfoName classicDomainToInfoName(Classic_Domain classicDomain) {
return new InfoName(classicDomain.name + "." + classicDomain.topLevelDomain + (classicDomain.path.startsWith("/") ? classicDomain.path : "/" + classicDomain.path));
}
/**
* Converts a InfoName object to a Classic_Domain object.
*
* @param newInfoName the InfoName object to convert
* @param protocolBridge The reference to the ProtocolBridge object.
* @return the converted Classic_Domain object
*/
@SuppressWarnings(value = "deprecation")
public static Classic_Domain infoNameToClassicDomain(InfoName newInfoName, ProtocolBridge protocolBridge) {
return new Classic_Domain(newInfoName.getName(), newInfoName.getTopLevelName(), newInfoName.getDestination(protocolBridge), newInfoName.getPath(), protocolBridge);
}
/**
* Converts a Classic_ProtocolVersion to a ProtocolVersion.
*
* @param classicProtocolVersion the Classic_ProtocolVersion to convert
* @return the converted ProtocolVersion
*/
@SuppressWarnings(value = "deprecation")
public static ProtocolVersion classicProtocolVersionToNewProtocolVersion(Classic_ProtocolVersion classicProtocolVersion) {
if (classicProtocolVersion == Classic_ProtocolVersion.PV_1_0_0) return ProtocolVersion.PV_1_0_0_CLASSIC;
return null;
}
/**
* Converts a ProtocolVersion to a Classic_ProtocolVersion.
*
* @param newProtocolVersion the ProtocolVersion to convert
* @return the converted Classic_ProtocolVersion
*/
@SuppressWarnings(value = "deprecation")
public static Classic_ProtocolVersion newProtocolVersionToClassicProtocolVersion(ProtocolVersion newProtocolVersion) {
return Classic_ProtocolVersion.PV_1_0_0;
}
}

View File

@@ -82,7 +82,7 @@ public final class Classic_ClientListener extends EventListener {
public void onPing(Classic_PingPacketReceivedEvent event) { public void onPing(Classic_PingPacketReceivedEvent event) {
// If the domain is reachable, fetch the HTML content // If the domain is reachable, fetch the HTML content
if (event.reachable) { if (event.reachable) {
String destination = event.domain.getInfoName().getDestination(protocolBridge); String destination = event.domain.destination;
try { try {
// Create a URL object // Create a URL object
@@ -102,7 +102,7 @@ public final class Classic_ClientListener extends EventListener {
} catch (IOException exception) { } catch (IOException exception) {
// Handle any exceptions that occur during the process // Handle any exceptions that occur during the process
protocolBridge.getClassicHandlerClient().handleHTMLContent(Classic_SiteType.PROTOCOL, new Classic_LocalDomain("error-occurred", "html", "", protocolBridge), protocolBridge.getClassicHandlerClient().handleHTMLContent(Classic_SiteType.PROTOCOL, new Classic_LocalDomain("error-occurred", "html", "", protocolBridge),
Classic_WebsitesContent.ERROR_OCCURRED(exception.getMessage().replace(event.domain.getInfoName().getDestination(protocolBridge), event.domain + "/" + event.domain.path))); Classic_WebsitesContent.ERROR_OCCURRED(exception.getMessage().replace(event.domain.destination, event.domain + "/" + event.domain.path)));
} }
} else } else
// If the domain is not reachable, handle the error // If the domain is not reachable, handle the error