6198 resolve empty space merge conflcits

This commit is contained in:
William Schaefer
2020-03-26 10:24:35 -04:00
8 changed files with 106 additions and 81 deletions
@@ -23,6 +23,8 @@ import java.util.List;
import java.util.Optional;
import org.apache.commons.validator.routines.DomainValidator;
import org.apache.commons.validator.routines.EmailValidator;
import org.sleuthkit.datamodel.CommunicationsUtils;
import org.sleuthkit.datamodel.TskCoreException;
/**
* Provides functions for normalizing data by attribute type before insertion or
@@ -152,26 +154,25 @@ final public class CorrelationAttributeNormalizer {
}
/**
* Verify that there is an '@' and no invalid characters. Should normalize
* to lower case.
* Verify and normalize email address.
*/
private static String normalizeEmail(String data) throws CorrelationAttributeNormalizationException {
EmailValidator validator = EmailValidator.getInstance(true, true);
if (validator.isValid(data)) {
return data.toLowerCase();
} else {
throw new CorrelationAttributeNormalizationException(String.format("Data was expected to be a valid email address: %s", data));
}
try {
return CommunicationsUtils.normalizeEmailAddress(data);
}
catch(TskCoreException ex) {
throw new CorrelationAttributeNormalizationException(String.format("Data was expected to be a valid email address: %s", data), ex);
}
}
/**
* Verify it is only numbers and '+'. Strip spaces, dashes, and parentheses.
* Verify and normalize phone number.
*/
private static String normalizePhone(String data) throws CorrelationAttributeNormalizationException {
if (data.matches("\\+?[0-9()\\-\\s]+")) {
String phoneNumber = data.replaceAll("[^0-9\\+]", "");
return phoneNumber;
} else {
try {
return CommunicationsUtils.normalizePhoneNum(data);
}
catch(TskCoreException ex) {
throw new CorrelationAttributeNormalizationException(String.format("Data was expected to be a valid phone number: %s", data));
}
}
@@ -33,6 +33,7 @@ import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.FileAttachment;
import org.sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments;
import org.sleuthkit.datamodel.CommunicationsUtils;
/**
*
@@ -97,20 +98,27 @@ class AccountSummary {
boolean isReference = false;
for (BlackboardAttribute attribute: attributes) {
for (BlackboardAttribute attribute : attributes) {
String attributeTypeName = attribute.getAttributeType().getTypeName();
String attributeValue = attribute.getValueString();
if (attributeTypeName.contains("PHONE")) {
attributeValue = RelationshipsNodeUtilities.normalizePhoneNum(attributeValue);
} else if (attributeTypeName.contains("EMAIL")) {
attributeValue = RelationshipsNodeUtilities.normalizeEmailAddress(attributeValue);
}
if ( typeSpecificID.equals(attributeValue) ) {
isReference = true;
break;
try {
if (attributeTypeName.contains("PHONE")) {
attributeValue = CommunicationsUtils.normalizePhoneNum(attributeValue);
} else if (attributeTypeName.contains("EMAIL")) {
attributeValue = CommunicationsUtils.normalizeEmailAddress(attributeValue);
}
if (typeSpecificID.equals(attributeValue)) {
isReference = true;
break;
}
} catch (TskCoreException ex) {
logger.log(Level.WARNING, String.format("Exception thrown "
+ "in trying to normalize attribute value: %s",
attributeValue), ex); //NON-NLS
}
}
if (isReference) {
referenceCnt++;
@@ -69,42 +69,4 @@ final class RelationshipsNodeUtilities {
}
}
/**
* Normalize the phone number by removing all non numeric characters, except
* for leading +.
*
* This function copied from CommunicationManager.
*
* @param phoneNum The phone number to normalize
*
* @return The normalized phone number.
*/
static String normalizePhoneNum(String phoneNum) {
String normailzedPhoneNum = phoneNum.replaceAll("\\D", "");
if (phoneNum.startsWith("+")) {
normailzedPhoneNum = "+" + normailzedPhoneNum;
}
if (normailzedPhoneNum.isEmpty()) {
normailzedPhoneNum = phoneNum;
}
return normailzedPhoneNum;
}
/**
* Normalize the given email address by converting it to lowercase.
*
* This function copied from CommunicationManager.
*
* @param emailAddress The email address tot normalize
*
* @return The normalized email address.
*/
static String normalizeEmailAddress(String emailAddress) {
String normailzedEmailAddr = emailAddress.toLowerCase();
return normailzedEmailAddr;
}
}
@@ -170,7 +170,6 @@ public class DocumentPanel extends javax.swing.JPanel implements ListCellRendere
numberOfImagesLabel.setText(Bundle.DocumentPanel_numberOfImages_noImages());
sampleImageLabel.setIcon(null);
}
nameLabel.setText(nameText);
previewTextPane.setText(value.getSummary().getSummaryText());
previewTextPane.setCaretPosition(0);