Skip to content

Commit

Permalink
LSNBLDR-589; make sure path in log entry is < 255 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
clhedrick committed Mar 30, 2016
1 parent a90ef9d commit 7715130
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4453,6 +4453,31 @@ public void track(long itemId, String path) {
}

public void track(long itemId, String path, Long studentPageId) {
if (path != null) {
List<String> pathItems = new ArrayList<String>(Arrays.asList(path.split(",")));
int last = pathItems.size();
path = "";
for (int i = 0; i < last; i ++) {
String item = pathItems.get(i);
int lastIndex = pathItems.lastIndexOf(item);
if (lastIndex > i) {
// item occurs more than once. kill intermediates
for (int j = i; j < lastIndex; j++)
pathItems.remove(i); // as we remove, the index stays the same
last -= (lastIndex - i); // number of items removed
}
// reconstruct string; will have extra , at the beginning
path += "," + item;
}
// now make sure it's not too long for database field
while (path.length() > 255) {
int i = path.indexOf(",", 1);
if (i > 0)
path = path.substring(i); // kill first item
}
path = path.substring(1); // kill initial comma
}

String userId = getCurrentUserId();
if (userId == null)
userId = ".anon";
Expand Down

0 comments on commit 7715130

Please sign in to comment.