19 package org.turro.contacts.relation;
21 import java.net.URISyntaxException;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import org.turro.url.URIs;
25 import org.turro.contacts.BusinessRelation;
26 import org.turro.contacts.Connector;
27 import org.turro.contacts.RelationValidation;
28 import org.turro.contacts.db.ContactsPU;
29 import org.turro.contacts.organigram.RelationType;
30 import org.turro.elephant.context.ElephantContext;
31 import org.turro.elephant.security.IUser;
32 import org.turro.jpa.DaoTransaction;
45 this.relation = relation;
60 return validation !=
null && !validation.
isValidated();
67 private void updateRule() {
72 }
else if(isInternal()) {
73 validation.
setRule(ValidationRule.VALIDATION_INTERNAL);
75 validation.
setRule(ValidationRule.VALIDATION_DUBIOUS);
79 private boolean isInternal() {
83 return URIs.sameBaseDomain(ElephantContext.getServerBase(
"http"), email.getValue());
84 }
catch (URISyntaxException ex) {
85 Logger.getLogger(
ValidationStatus.class.getName()).log(Level.INFO,
null, ex);
91 private BusinessRelation getHHRR() {
92 return workers.stream().filter(r -> RelationType.REL_HHRR.equals(r.getType())).findFirst().orElse(
null);
95 private boolean hasSameDomain() {
100 if(web !=
null && URIs.sameBaseDomain(web.getValue(), email.getValue())) {
105 String[] domains = domain.getValue().split(
"\\s*,\\s*");
106 for(String d : domains) {
107 if(URIs.sameBaseDomain(d, email.getValue())) {
113 }
catch (URISyntaxException ex) {
114 Logger.getLogger(
ValidationStatus.class.getName()).log(Level.INFO,
null, ex);
119 private void saveStatus() {
120 try(DaoTransaction transaction =
new DaoTransaction(
new ContactsPU())) {
122 transaction.saveObject(validation);
124 transaction.saveObject(relation);