MCPcopy Create free account
hub / github.com/OWASP/SecurityShepherd / findCreateClassId

Method findCreateClassId

src/test/java/dbProcs/GetterTest.java:63–90  ·  view source on GitHub ↗

Searches for class based on class name. If nothing is found, the class is created and the new class Id is returned @param className Name of the class you wish to search / create @return The Identifier of the class owning the name submitted @throws Exception If the class cannot be created or found

(String className)

Source from the content-addressed store, hash-verified

61 * @throws Exception If the class cannot be created or found
62 */
63 public static String findCreateClassId(String className) throws Exception
64 {
65 String classId = new String();
66 ResultSet rs = Getter.getClassInfo(applicationRoot);
67 while(rs.next())
68 {
69 if(rs.getString(2).compareTo(className) == 0)
70 {
71 classId = rs.getString(1);
72 break;
73 }
74 }
75 rs.close();
76 if(classId.isEmpty())
77 {
78 log.debug("Could not find class. Creating it");
79 if(Setter.classCreate(applicationRoot, className, "2015"))
80 {
81 log.debug("Class Created. Getting ID");
82 classId = findCreateClassId(className);
83 }
84 else
85 {
86 throw new Exception("Could not Create Class " + className);
87 }
88 }
89 return classId;
90 }
91
92 /**
93 * Searches for class based on class name. If nothing is found, the class is created and the new class Id is returned

Calls 2

getClassInfoMethod · 0.95
classCreateMethod · 0.95

Tested by

no test coverage detected