Skip to content

Commit

Permalink
Merge pull request #23 from Comcast/BidiCollectorImplementation
Browse files Browse the repository at this point in the history
v2.0.4
  • Loading branch information
Maurice Garcia committed May 10, 2015
2 parents 29b275d + 4fc2dfb commit 168898d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
Binary file added lib/commons-collections4-4.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/com/comcast/oscar/constants/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Constants {

private static final String TAB = "\t";

public static final String OSCAR_VERSION = "2.0.3.1";
public static final String OSCAR_VERSION = "2.0.4";
public static final String OSCAR_CLI_USAGE = "java -jar oscar.jar -k <key> -i <.txt> -o <.bin> -c";
public static final String OSCAR_CLI_HEADER = "/* OSCAR -> OpenSource Cable modem file AssembleR v" + OSCAR_VERSION + " */";
public static final String OSCAR_CLI_NO_ARGS = "Type --help for information";
Expand Down
33 changes: 19 additions & 14 deletions src/com/comcast/oscar/netsnmp/NetSNMP.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;

import com.comcast.oscar.utilities.DirectoryStructure;
import com.comcast.oscar.utilities.Disk;
Expand Down Expand Up @@ -39,19 +40,19 @@ public class NetSNMP {
private static Boolean debug = Boolean.FALSE;

private static ObjectMapper omNetSNMP = null;
private static Map<String,String> hmDotTextMap = null;
private static BidiMap<String, String> bmDotTextMap = null;

static {

FixNullNetSNMPJSON();

omNetSNMP = new ObjectMapper();

hmDotTextMap = new HashMap<String,String>();
bmDotTextMap = new DualHashBidiMap<String,String>();

try {
hmDotTextMap = omNetSNMP.readValue(DirectoryStructureNetSNMP.fNetSNMPJSON(),
new TypeReference<HashMap<String, String>>() {});
bmDotTextMap = omNetSNMP.readValue(DirectoryStructureNetSNMP.fNetSNMPJSON(),
new TypeReference<DualHashBidiMap<String, String>>() {});
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
Expand Down Expand Up @@ -291,13 +292,11 @@ public static File fNetSNMPJSON()
* @param sOIDConvert
*/
private static void UpdateJsonDB(String sOIDKey, String sOIDConvert) {

/*TODO to go back and use a bidirectional collector */
hmDotTextMap.put(sOIDKey, sOIDConvert);
hmDotTextMap.put(sOIDConvert, sOIDKey);

bmDotTextMap.put(sOIDKey, sOIDConvert);

try {
omNetSNMP.writeValue(DirectoryStructureNetSNMP.fNetSNMPJSON(), hmDotTextMap);
omNetSNMP.writeValue(DirectoryStructureNetSNMP.fNetSNMPJSON(), bmDotTextMap);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
Expand All @@ -317,13 +316,19 @@ private static String CheckOIDDBLookup(String sOID) {

String sReturn = "";

if (hmDotTextMap.containsKey(sOID)) {
if (bmDotTextMap.containsKey(sOID)) {

if (debug)
System.out.println("CheckOIDDBLookup().containsKey " + sOID + " -> " + hmDotTextMap.get(sOID));
System.out.println("CheckOIDDBLookup().containsKey " + sOID + " -> " + bmDotTextMap.get(sOID));

return hmDotTextMap.get(sOID);
return bmDotTextMap.get(sOID);

} else if (bmDotTextMap.containsValue(sOID)) {

if (debug)
System.out.println("CheckOIDDBLookup().containsValue " + sOID + " -> " + bmDotTextMap.getKey(sOID));

return bmDotTextMap.getKey(sOID);
}

return sReturn;
Expand Down

0 comments on commit 168898d

Please sign in to comment.