-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
058a93f
commit 23831da
Showing
5 changed files
with
128 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
libs/dao/src/main/java/com/akto/dao/VulnerabilityReportPDFDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.akto.dao; | ||
|
||
import com.akto.dao.context.Context; | ||
import com.akto.dto.VulnerabilityReportPDF; | ||
import com.mongodb.client.MongoDatabase; | ||
|
||
public class VulnerabilityReportPDFDao extends AccountsContextDao<VulnerabilityReportPDF> { | ||
|
||
public static final VulnerabilityReportPDFDao instance = new VulnerabilityReportPDFDao(); | ||
|
||
public VulnerabilityReportPDFDao() {} | ||
|
||
@Override | ||
public String getCollName() { | ||
return "vulnerability_report_pdf"; | ||
} | ||
|
||
@Override | ||
public Class<VulnerabilityReportPDF> getClassT() { | ||
return VulnerabilityReportPDF.class; | ||
} | ||
|
||
|
||
public void createIndicesIfAbsent() { | ||
boolean exists = false; | ||
String dbName = Context.accountId.get()+""; | ||
MongoDatabase db = clients[0].getDatabase(dbName); | ||
for (String col: db.listCollectionNames()){ | ||
if (getCollName().equalsIgnoreCase(col)){ | ||
exists = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!exists) { | ||
db.createCollection(getCollName()); | ||
} | ||
|
||
MCollection.createIndexIfAbsent(getDBName(), getCollName(), new String[] { VulnerabilityReportPDF.VULNERABILITY_REPORT_URL }, false); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
libs/dao/src/main/java/com/akto/dto/VulnerabilityReportPDF.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.akto.dto; | ||
|
||
public class VulnerabilityReportPDF { | ||
|
||
public static final String VULNERABILITY_REPORT_URL = "vulnerabilityReportUrl"; | ||
private String vulnerabilityReportUrl; | ||
|
||
public static final String VULNERABILITY_REPORT_PDF_BINARY = "vulnerabilityReportPDFBinary"; | ||
private String vulnerabilityReportPDFBinary; | ||
|
||
public static final String LAST_UPDATE_TIME_STAMP = "lastUpdateTimeStamp"; | ||
private int lastUpdateTimestamp; | ||
|
||
public VulnerabilityReportPDF() {} | ||
|
||
public VulnerabilityReportPDF(String vulnerabilityReportUrl, String vulnerabilityReportPDFBinary, int lastUpdateTimestamp) { | ||
this.vulnerabilityReportUrl = vulnerabilityReportUrl; | ||
this.vulnerabilityReportPDFBinary = vulnerabilityReportPDFBinary; | ||
this.lastUpdateTimestamp = lastUpdateTimestamp; | ||
} | ||
|
||
public String getVulnerabilityReportUrl() { | ||
return vulnerabilityReportUrl; | ||
} | ||
|
||
public void setVulnerabilityReportUrl(String vulnerabilityReportUrl) { | ||
this.vulnerabilityReportUrl = vulnerabilityReportUrl; | ||
} | ||
|
||
public String getVulnerabilityReportPDFBinary() { | ||
return vulnerabilityReportPDFBinary; | ||
} | ||
|
||
public void setVulnerabilityReportPDFBinary(String vulnerabilityReportPDFBinary) { | ||
this.vulnerabilityReportPDFBinary = vulnerabilityReportPDFBinary; | ||
} | ||
|
||
public int getLastUpdateTimestamp() { | ||
return lastUpdateTimestamp; | ||
} | ||
|
||
public void setLastUpdateTimestamp(int lastUpdateTimestamp) { | ||
this.lastUpdateTimestamp = lastUpdateTimestamp; | ||
} | ||
} |