Removed InfoName Class
This commit is contained in:
@@ -36,27 +36,20 @@ public class Classic_Domain implements Serializable {
|
||||
* The destination of the domain, typically the full URL or address.
|
||||
*/
|
||||
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
|
||||
private final String destination;
|
||||
public final String destination;
|
||||
|
||||
/**
|
||||
* The ProtocolBridge reference.
|
||||
*/
|
||||
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
|
||||
private final ProtocolBridge protocolBridge;
|
||||
|
||||
/**
|
||||
* The encapsulated Domain object for modern usage.
|
||||
*/
|
||||
@Getter
|
||||
private final InfoName infoName;
|
||||
public final ProtocolBridge protocolBridge;
|
||||
|
||||
public Classic_Domain(String name, String topLevelDomain, String destination, String path, ProtocolBridge bridge) {
|
||||
this.protocolBridge = bridge;
|
||||
this.infoName = new InfoName(name + "." + topLevelDomain + "/" + (path.startsWith("/") ? path : "/" + path));
|
||||
this.name = infoName.getName();
|
||||
this.topLevelDomain = infoName.getTopLevelName();
|
||||
this.destination = infoName.getDestination(bridge);
|
||||
this.path = infoName.getPath();
|
||||
this.name = name;
|
||||
this.topLevelDomain = topLevelDomain;
|
||||
this.destination = destination;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public final class Classic_ClientListener extends EventListener {
|
||||
public void onPing(Classic_PingPacketReceivedEvent event) {
|
||||
// If the domain is reachable, fetch the HTML content
|
||||
if (event.reachable) {
|
||||
String destination = event.domain.getInfoName().getDestination(protocolBridge);
|
||||
String destination = event.domain.destination;
|
||||
|
||||
try {
|
||||
// Create a URL object
|
||||
@@ -102,7 +102,7 @@ public final class Classic_ClientListener extends EventListener {
|
||||
} catch (IOException exception) {
|
||||
// Handle any exceptions that occur during the process
|
||||
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
|
||||
// If the domain is not reachable, handle the error
|
||||
|
||||
Reference in New Issue
Block a user