21 import java.io.Serializable;
22 import java.net.UnknownHostException;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import javax.persistence.Entity;
27 import javax.persistence.Id;
28 import javax.persistence.IdClass;
29 import org.turro.string.Phrases;
30 import org.turro.string.Strings;
31 import org.turro.url.URIs;
32 import org.turro.action.Contacts;
33 import org.turro.elephant.context.ElephantContext;
34 import org.turro.jpa.entity.IDaoEntity;
35 import org.turro.json.IJSONizable;
36 import org.turro.plugin.contacts.IContact;
37 import org.turro.util.Chars;
44 @IdClass(WsServerPK.class)
47 @Id
private String serverDomain;
48 @Id
private String service;
50 private String contactId;
57 this.serverDomain = serverDomain;
65 this.service = service;
73 this.contactId = contactId;
80 String[] parts = serverDomain.split(
"[\\:\\/]");
81 return URIs.validIP(parts[0], ip);
82 }
catch (UnknownHostException ex) {
89 return getServerDomain() + getService();
93 return Phrases.start(getContact().getName(), Chars.forward().toString(), getService()).toString();
97 return "serverDomain=%s&service=%s".formatted(serverDomain, service);
105 return serviceName ==
null ?
new ServiceNamePair(service, service) : serviceName;
109 this.serviceName = serviceName;
120 contactId = contact ==
null ? null : contact.
getId();
132 return Strings.isBlank(contactId) || Strings.isBlank(serverDomain);
143 public String
toJson(Map<String, Object> properties) {
144 return toJson(
this, properties);
static String logMsg(String msg)
static WsServerPK from(String serverDomain, String service)
static WsServer from(String serverDomain, String service)
void setContactId(String contactId)
boolean isValidIP(String ip)
ServiceNamePair getServiceName()
void setService(String service)
void setServiceName(ServiceNamePair serviceName)
void setContact(IContact contact)
void setServerDomain(String serverDomain)
String toJson(Map< String, Object > properties)