Skip to content

Commit 13d296a

Browse files
authored
devrev create ticket API (#3741)
* create devrev ticket api * fix existing issues error * fix hostname handling * fix successful result
1 parent 8b5646f commit 13d296a

File tree

5 files changed

+576
-7
lines changed

5 files changed

+576
-7
lines changed

apps/dashboard/src/main/java/com/akto/action/DevRevIntegrationAction.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import com.akto.devrev.DevRevIntegrationService;
44
import com.akto.dto.devrev_integration.DevRevIntegration;
5+
import com.akto.dto.test_run_findings.TestingIssuesId;
56
import com.akto.log.LoggerMaker;
7+
import com.akto.ticketing.ATicketIntegrationService.TicketCreationResult;
68
import com.opensymphony.xwork2.Action;
9+
import java.util.List;
10+
import java.util.Map;
711
import lombok.Getter;
812
import lombok.Setter;
913

10-
import java.util.Map;
11-
1214
@Getter
1315
@Setter
1416
public class DevRevIntegrationAction extends UserAction {
@@ -19,6 +21,11 @@ public class DevRevIntegrationAction extends UserAction {
1921
private String personalAccessToken;
2022
private DevRevIntegration devrevIntegration;
2123
private Map<String, String> partsIdToNameMap;
24+
private List<TestingIssuesId> testingIssuesIdList;
25+
private String partId;
26+
private String workItemType;
27+
private String errorMessage;
28+
private String aktoDashboardHost;
2229

2330
public String addDevRevIntegration() {
2431
try {
@@ -35,7 +42,7 @@ public String addDevRevIntegration() {
3542
public String fetchDevRevIntegration() {
3643
try {
3744
DevRevIntegrationService devRevService = new DevRevIntegrationService();
38-
devrevIntegration = devRevService.fetchIntegration();
45+
devrevIntegration = devRevService.fetchDevRevIntegration();
3946
return Action.SUCCESS.toUpperCase();
4047
} catch (Exception e) {
4148
logger.errorAndAddToDb("Error fetching DevRev integration: " + e.getMessage(), LoggerMaker.LogDb.DASHBOARD);
@@ -67,4 +74,19 @@ public String removeDevRevIntegration() {
6774
return Action.ERROR.toUpperCase();
6875
}
6976
}
77+
78+
public String createDevRevTickets() {
79+
try {
80+
DevRevIntegrationService devRevService = new DevRevIntegrationService();
81+
TicketCreationResult result = devRevService.createTickets(testingIssuesIdList, partId, workItemType, aktoDashboardHost);
82+
83+
this.errorMessage = result.getMessage();
84+
85+
return Action.SUCCESS.toUpperCase();
86+
} catch (Exception e) {
87+
logger.errorAndAddToDb("Error creating DevRev tickets: " + e.getMessage(), LoggerMaker.LogDb.DASHBOARD);
88+
addActionError(e.getMessage());
89+
return Action.ERROR.toUpperCase();
90+
}
91+
}
7092
}

apps/dashboard/src/main/java/com/akto/action/ProfileAction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ public static void executeMeta1(Utility utility, User user, HttpServletRequest r
138138
} catch (Exception e) {
139139
}
140140

141+
boolean devrevIntegrated = false;
142+
try {
143+
long documentCount = DevRevIntegrationDao.instance.estimatedDocumentCount();
144+
if (documentCount > 0) {
145+
devrevIntegrated = true;
146+
}
147+
} catch (Exception e) {
148+
}
149+
141150
InitializerListener.insertStateInAccountSettings(accountSettings);
142151

143152
Organization organization = OrganizationsDao.instance.findOne(
@@ -178,6 +187,7 @@ public static void executeMeta1(Utility utility, User user, HttpServletRequest r
178187
.append("jiraIntegrated", jiraIntegrated)
179188
.append("azureBoardsIntegrated", azureBoardsIntegrated)
180189
.append("servicenowIntegrated", servicenowIntegrated)
190+
.append("devrevIntegrated", devrevIntegrated)
181191
.append("userRole", userRole.toString().toUpperCase())
182192
.append("currentTimeZone", timeZone)
183193
.append("organizationName", orgName)

apps/dashboard/src/main/resources/struts.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11735,6 +11735,39 @@
1173511735
</result>
1173611736
</action>
1173711737

11738+
<action name="api/createDevRevTickets" class="com.akto.action.DevRevIntegrationAction" method="createDevRevTickets" >
11739+
<interceptor-ref name="json"/>
11740+
<interceptor-ref name="defaultStack" />
11741+
<interceptor-ref name="roleAccessInterceptor">
11742+
<param name="featureLabel">INTEGRATIONS</param>
11743+
<param name="accessType">READ_WRITE</param>
11744+
<param name="actionDescription">User created DevRev tickets</param>
11745+
</interceptor-ref>
11746+
11747+
<result name="FORBIDDEN" type="json">
11748+
<param name="statusCode">403</param>
11749+
<param name="ignoreHierarchy">false</param>
11750+
<param name="includeProperties">^actionErrors.*</param>
11751+
</result>
11752+
<interceptor-ref name="usageInterceptor">
11753+
<param name="featureLabel">DEVREV_INTEGRATION</param>
11754+
</interceptor-ref>
11755+
<result name="SUCCESS" type="json">
11756+
<param name="ignoreHierarchy">false</param>
11757+
<param name="includeProperties">^errorMessage.*</param>
11758+
</result>
11759+
<result name="ERROR" type="json">
11760+
<param name="statusCode">422</param>
11761+
<param name="ignoreHierarchy">false</param>
11762+
<param name="includeProperties">^actionErrors.*, ^responses.*</param>
11763+
</result>
11764+
<result name="UNAUTHORIZED" type="json">
11765+
<param name="statusCode">403</param>
11766+
<param name="ignoreHierarchy">false</param>
11767+
<param name="includeProperties">^actionErrors.*</param>
11768+
</result>
11769+
</action>
11770+
1173811771
<action name="api/fetchServiceNowIntegration" class="com.akto.action.ServiceNowIntegrationAction" method="fetchServiceNowIntegration" >
1173911772
<interceptor-ref name="json"/>
1174011773
<interceptor-ref name="defaultStack" />

0 commit comments

Comments
 (0)