Skip to content

Commit

Permalink
Merge branch 'development' of github.com:Pardus-LiderAhenk/liderapi i…
Browse files Browse the repository at this point in the history
…nto development
  • Loading branch information
agahhulusi committed Mar 22, 2023
2 parents 2400b98 + 6c47d8d commit b7daf73
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ public ResponseEntity<List<PolicyExceptionImpl>> policyExceptionListByPolicy(@Pa
.status(HttpStatus.OK)
.body(policyExceptionService.listByPolicy(policyService.findPolicyByID(id).getId()));
}

@Operation(summary = "Get policy exception list by policy id and by selected group dn", description = "", tags = { "policy-exception" })
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Returns policy exception list successfully"),
@ApiResponse(responseCode = "417", description = "Could not get policy exception list. Unexpected error occurred",
content = @Content(schema = @Schema(implementation = String.class))) })
@GetMapping(value = "/list/policy/{id}/group-dn/{dn}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<PolicyExceptionImpl>> policyExceptionListByPolicyByDn(@PathVariable Long id, @PathVariable String dn) {
return ResponseEntity
.status(HttpStatus.OK)
.body(policyExceptionService.findByPolicyAndGroupDn(policyService.findPolicyByID(id), dn));
}

// return saved policy
//@RequestMapping(method=RequestMethod.POST ,value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down Expand Up @@ -166,6 +178,7 @@ else if(configService.getDomainType().equals(DomainType.LDAP) || configService.g
policyExceptionImpl.setLabel(params.getLabel());
policyExceptionImpl.setDn(dnList.get(j));
policyExceptionImpl.setDnType(DNType.GROUP);
policyExceptionImpl.setGroupDn(params.getGroupDn());
policyExceptionService.add(policyExceptionImpl);
}
} else {
Expand All @@ -176,6 +189,7 @@ else if(configService.getDomainType().equals(DomainType.LDAP) || configService.g
policyExceptionImpl.setLabel(params.getLabel());
policyExceptionImpl.setDn(params.getMembers().get(i).toString());
policyExceptionImpl.setDnType(getLdapEntry(params.getMembers().get(i).toString()).getType());
policyExceptionImpl.setGroupDn(params.getGroupDn());
policyExceptionService.add(policyExceptionImpl);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public ResponseEntity<LdapEntry> deleteMembersOfGroup(@RequestParam(value="dn",
//so dn must be joined with comma
//if member dn that will be added to group is cn=agent1,ou=Groups,dn=liderahenk,dc=org
//spring boot gets this param as array which has size 4
String dnStringTemp = String.join(",", dn);
String dnStringTemp = String.join(",", dnList);
List <String> dnListTemp = new ArrayList<>();
dnListTemp.add(dnStringTemp);
DNType dnType= null;
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/tr/org/lider/entities/PolicyExceptionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
Expand Down Expand Up @@ -93,6 +90,9 @@ public class PolicyExceptionImpl implements Serializable {
@Column(name = "DN",columnDefinition = "TEXT", length = 1000, nullable = false)
private String dn;

@Column(name = "GROUP_DN",columnDefinition = "TEXT", length = 1000, nullable = false)
private String groupDn;

@Transient
private List<?> members;

Expand Down Expand Up @@ -196,6 +196,14 @@ public String getDn() {
public void setDn(String dn) {
this.dn = dn;
}

public String getGroupDn() {
return groupDn;
}

public void setGroupDn(String groupDn) {
this.groupDn = groupDn;
}

public void setModifyDate(Date modifyDate) {
this.modifyDate = modifyDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public interface PolicyExceptionRepository extends BaseJpaRepository<PolicyExcep
List<PolicyExceptionImpl> findByPolicy(Long id);

List<PolicyExceptionImpl> findByPolicyAndDn(PolicyImpl policy, String dn);

List<PolicyExceptionImpl> findByPolicyAndGroupDn(PolicyImpl policy, String dn);

@Transactional
@Modifying(clearAutomatically = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public List<PolicyExceptionImpl> findByPolicyAndDn(PolicyImpl policy, String dn)
return policyExceptionRepository.findByPolicyAndDn(policy, dn);
}

public List<PolicyExceptionImpl> findByPolicyAndGroupDn(PolicyImpl policy, String dn){
return policyExceptionRepository.findByPolicyAndGroupDn(policy, dn);
}

public PolicyExceptionImpl add(PolicyExceptionImpl policyExceptionImpl) {
PolicyExceptionImpl existPolicyException = policyExceptionRepository.save(policyExceptionImpl);
return existPolicyException;
Expand Down

0 comments on commit b7daf73

Please sign in to comment.