9
9
10
10
import com .atlassian .activeobjects .external .ActiveObjects ;
11
11
import com .atlassian .bitbucket .event .repository .AbstractRepositoryRefsChangedEvent ;
12
+ import com .atlassian .bitbucket .event .repository .RepositoryDeletedEvent ;
12
13
import com .atlassian .bitbucket .repository .RefChange ;
13
14
import com .atlassian .bitbucket .repository .RefChangeType ;
14
15
import com .atlassian .bitbucket .repository .Repository ;
@@ -79,6 +80,17 @@ public void onRefsChanged(AbstractRepositoryRefsChangedEvent event) {
79
80
}
80
81
}
81
82
83
+ @ EventListener
84
+ public void onRepositoryDeleted (RepositoryDeletedEvent event ) {
85
+ Repository repo = event .getRepository ();
86
+
87
+ Integer repoId = repo .getId ();
88
+
89
+ log .info ("RepositoryDeletedEvent: Delete all branch authors in a repo. repoId={}" , repoId );
90
+
91
+ deleteAllBranchAuthor (repoId );
92
+ }
93
+
82
94
private void createBranchAuthor (Integer repoId , Date created , String branchRef , Integer userId , String userEmail ) {
83
95
try {
84
96
BranchAuthorImpl .saveBranchAuthor (activeObjects , repoId , created , branchRef , userId , userEmail );
@@ -94,4 +106,12 @@ private void deleteBranchAuthor(Integer repoId, String branchRef) {
94
106
log .error ("Deleting branch author error. repoid={}, branchRef={}" , repoId , branchRef , e );
95
107
}
96
108
}
109
+
110
+ private void deleteAllBranchAuthor (Integer repoId ) {
111
+ try {
112
+ BranchAuthorImpl .deleteAllBranchAuthor (activeObjects , repoId );
113
+ } catch (SQLException e ) {
114
+ log .error ("Deleting branch authors error. repoid={}" , repoId , e );
115
+ }
116
+ }
97
117
}
0 commit comments