|
23 | 23 | import javax.inject.Inject; |
24 | 24 | import javax.naming.ConfigurationException; |
25 | 25 |
|
| 26 | +import com.cloud.server.ResourceTag.ResourceObjectType; |
| 27 | +import com.cloud.tags.dao.ResourceTagDao; |
26 | 28 | import org.springframework.stereotype.Component; |
27 | 29 |
|
28 | 30 | import com.cloud.network.security.SecurityGroupRuleVO; |
|
32 | 34 | import com.cloud.utils.db.JoinBuilder; |
33 | 35 | import com.cloud.utils.db.SearchBuilder; |
34 | 36 | import com.cloud.utils.db.SearchCriteria; |
| 37 | +import com.cloud.utils.db.TransactionLegacy; |
| 38 | +import com.cloud.utils.db.DB; |
35 | 39 |
|
36 | 40 | @Component |
37 | 41 | @Local(value = {SecurityGroupRuleDao.class}) |
38 | 42 | public class SecurityGroupRuleDaoImpl extends GenericDaoBase<SecurityGroupRuleVO, Long> implements SecurityGroupRuleDao { |
39 | 43 |
|
40 | 44 | @Inject |
41 | 45 | SecurityGroupDao _securityGroupDao; |
| 46 | + @Inject |
| 47 | + ResourceTagDao _tagsDao; |
42 | 48 |
|
43 | 49 | protected SearchBuilder<SecurityGroupRuleVO> securityGroupIdSearch; |
44 | 50 | protected SearchBuilder<SecurityGroupRuleVO> securityGroupIdAndTypeSearch; |
@@ -174,4 +180,18 @@ public SecurityGroupRuleVO findByProtoPortsAndAllowedGroupId(long securityGroupI |
174 | 180 | sc.setParameters("allowedNetworkId", allowedGroupId); |
175 | 181 | return findOneIncludingRemovedBy(sc); |
176 | 182 | } |
| 183 | + |
| 184 | + @Override |
| 185 | + @DB |
| 186 | + public boolean remove(Long id) { |
| 187 | + TransactionLegacy txn = TransactionLegacy.currentTxn(); |
| 188 | + txn.start(); |
| 189 | + SecurityGroupRuleVO entry = findById(id); |
| 190 | + if (entry != null) { |
| 191 | + _tagsDao.removeByIdAndType(id, ResourceObjectType.SecurityGroupRule); |
| 192 | + } |
| 193 | + boolean result = super.remove(id); |
| 194 | + txn.commit(); |
| 195 | + return result; |
| 196 | + } |
177 | 197 | } |
0 commit comments