Skip to content

Commit 7955efc

Browse files
committed
Revert "Remove Unused Files"
This reverts commit c48bd99 as it was erroneously applied to this branch.
1 parent c48bd99 commit 7955efc

File tree

3 files changed

+392
-0
lines changed

3 files changed

+392
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
/*
2+
* Copyright 2005-2013 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.ldap.itest.transaction.compensating.manager;
18+
19+
import org.springframework.jdbc.core.JdbcTemplate;
20+
import org.springframework.ldap.core.DirContextAdapter;
21+
import org.springframework.ldap.core.DistinguishedName;
22+
import org.springframework.ldap.core.LdapTemplate;
23+
import org.springframework.transaction.annotation.Transactional;
24+
25+
@Transactional
26+
public class LdapAndJdbcDummyDaoImpl implements DummyDao {
27+
28+
private LdapTemplate ldapTemplate;
29+
30+
private JdbcTemplate jdbcTemplate;
31+
32+
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
33+
this.jdbcTemplate = jdbcTemplate;
34+
}
35+
36+
public void setLdapTemplate(LdapTemplate ldapTemplate) {
37+
this.ldapTemplate = ldapTemplate;
38+
}
39+
40+
/*
41+
* (non-Javadoc)
42+
*
43+
* @see
44+
* org.springframework.ldap.transaction.support.DummyDao#createWithException(java.lang
45+
* .String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
46+
*/
47+
public void createWithException(String country, String company, String fullname, String lastname,
48+
String description) {
49+
create(country, company, fullname, lastname, description);
50+
throw new DummyException("This method failed");
51+
}
52+
53+
/*
54+
* (non-Javadoc)
55+
*
56+
* @see org.springframework.ldap.transaction.support.DummyDao#create(java.lang.String,
57+
* java.lang.String, java.lang.String, java.lang.String, java.lang.String)
58+
*/
59+
public void create(String country, String company, String fullname, String lastname, String description) {
60+
DistinguishedName dn = new DistinguishedName();
61+
dn.add("ou", country);
62+
dn.add("ou", company);
63+
dn.add("cn", fullname);
64+
65+
DirContextAdapter ctx = new DirContextAdapter();
66+
ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
67+
ctx.setAttributeValue("cn", fullname);
68+
ctx.setAttributeValue("sn", lastname);
69+
ctx.setAttributeValue("description", description);
70+
this.ldapTemplate.bind(dn, ctx, null);
71+
this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
72+
new Object[] { fullname, lastname, description });
73+
}
74+
75+
/*
76+
* (non-Javadoc)
77+
*
78+
* @see org.springframework.ldap.transaction.support.DummyDao#update(java.lang.String,
79+
* java.lang.String, java.lang.String)
80+
*/
81+
public void update(String dn, String fullname, String lastname, String description) {
82+
DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
83+
ctx.setAttributeValue("sn", lastname);
84+
ctx.setAttributeValue("description", description);
85+
86+
this.ldapTemplate.modifyAttributes(ctx);
87+
this.jdbcTemplate.update("update PERSON set lastname=?, description = ? where fullname = ?",
88+
new Object[] { lastname, description, fullname });
89+
}
90+
91+
/*
92+
* (non-Javadoc)
93+
*
94+
* @see
95+
* org.springframework.ldap.transaction.support.DummyDao#updateWithException(java.lang
96+
* .String, java.lang.String, java.lang.String)
97+
*/
98+
public void updateWithException(String dn, String fullname, String lastname, String description) {
99+
update(dn, fullname, lastname, description);
100+
throw new DummyException("This method failed.");
101+
}
102+
103+
/*
104+
* (non-Javadoc)
105+
*
106+
* @see
107+
* org.springframework.ldap.transaction.support.DummyDao#updateAndRename(java.lang.
108+
* String, java.lang.String, java.lang.String)
109+
*/
110+
public void updateAndRename(String dn, String newDn, String description) {
111+
DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
112+
ctx.setAttributeValue("description", description);
113+
114+
this.ldapTemplate.modifyAttributes(ctx);
115+
this.ldapTemplate.rename(dn, newDn);
116+
}
117+
118+
/*
119+
* (non-Javadoc)
120+
*
121+
* @see
122+
* org.springframework.ldap.transaction.support.DummyDao#updateAndRenameWithException(
123+
* java.lang.String, java.lang.String, java.lang.String)
124+
*/
125+
public void updateAndRenameWithException(String dn, String newDn, String description) {
126+
updateAndRename(dn, newDn, description);
127+
throw new DummyException("This method failed.");
128+
}
129+
130+
/*
131+
* (non-Javadoc)
132+
*
133+
* @see
134+
* org.springframework.ldap.transaction.support.DummyDao#modifyAttributes(java.lang.
135+
* String, java.lang.String, java.lang.String)
136+
*/
137+
public void modifyAttributes(String dn, String lastName, String description) {
138+
DirContextAdapter ctx = (DirContextAdapter) this.ldapTemplate.lookup(dn);
139+
ctx.setAttributeValue("sn", lastName);
140+
ctx.setAttributeValue("description", description);
141+
142+
this.ldapTemplate.modifyAttributes(dn, ctx.getModificationItems());
143+
}
144+
145+
/*
146+
* (non-Javadoc)
147+
*
148+
* @see
149+
* org.springframework.ldap.transaction.support.DummyDao#modifyAttributesWithException
150+
* (java.lang.String, java.lang.String, java.lang.String)
151+
*/
152+
public void modifyAttributesWithException(String dn, String lastName, String description) {
153+
modifyAttributes(dn, lastName, description);
154+
throw new DummyException("This method failed.");
155+
}
156+
157+
/*
158+
* (non-Javadoc)
159+
*
160+
* @see org.springframework.ldap.transaction.support.DummyDao#unbind(java.lang.String)
161+
*/
162+
public void unbind(String dn, String fullname) {
163+
this.ldapTemplate.unbind(dn);
164+
this.jdbcTemplate.update("delete from PERSON where fullname=?", new Object[] { fullname });
165+
}
166+
167+
/*
168+
* (non-Javadoc)
169+
*
170+
* @see
171+
* org.springframework.ldap.transaction.support.DummyDao#unbindWithException(java.lang
172+
* .String)
173+
*/
174+
public void unbindWithException(String dn, String fullname) {
175+
unbind(dn, fullname);
176+
throw new DummyException("This operation failed.");
177+
}
178+
179+
@Override
180+
public void deleteRecursively(String dn) {
181+
throw new UnsupportedOperationException();
182+
}
183+
184+
@Override
185+
public void deleteRecursivelyWithException(String dn) {
186+
throw new UnsupportedOperationException();
187+
}
188+
189+
@Override
190+
public void createRecursivelyAndUnbindSubnode() {
191+
throw new UnsupportedOperationException();
192+
}
193+
194+
@Override
195+
public void createRecursivelyAndUnbindSubnodeWithException() {
196+
throw new UnsupportedOperationException();
197+
}
198+
199+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*
2+
* Copyright 2005-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.ldap.itest.transaction.compensating.manager.hibernate;
18+
19+
/**
20+
* Pojo for use with the ContextSourceAndHibernateTransactionManager integration tests
21+
*
22+
* @author Hans Westerbeek
23+
*
24+
*/
25+
public class OrgPerson {
26+
27+
private Integer id;
28+
29+
private String fullname;
30+
31+
private String lastname;
32+
33+
private String company;
34+
35+
private String country;
36+
37+
private String description;
38+
39+
public Integer getId() {
40+
return this.id;
41+
}
42+
43+
public void setId(Integer id) {
44+
this.id = id;
45+
}
46+
47+
public String getFullname() {
48+
return this.fullname;
49+
}
50+
51+
public void setFullname(String fullname) {
52+
this.fullname = fullname;
53+
}
54+
55+
public String getLastname() {
56+
return this.lastname;
57+
}
58+
59+
public void setLastname(String lastname) {
60+
this.lastname = lastname;
61+
}
62+
63+
public String getCountry() {
64+
return this.country;
65+
}
66+
67+
public void setCountry(String country) {
68+
this.country = country;
69+
}
70+
71+
public String getCompany() {
72+
return this.company;
73+
}
74+
75+
public void setCompany(String company) {
76+
this.company = company;
77+
}
78+
79+
public String getDescription() {
80+
return this.description;
81+
}
82+
83+
public void setDescription(String description) {
84+
this.description = description;
85+
}
86+
87+
public boolean equals(Object obj) {
88+
if (this == obj) {
89+
return true;
90+
}
91+
if (obj == null) {
92+
return false;
93+
}
94+
if (getClass() != obj.getClass()) {
95+
return false;
96+
}
97+
final OrgPerson other = (OrgPerson) obj;
98+
if (this.company == null) {
99+
if (other.company != null) {
100+
return false;
101+
}
102+
}
103+
else if (!this.company.equals(other.company)) {
104+
return false;
105+
}
106+
if (this.country == null) {
107+
if (other.country != null) {
108+
return false;
109+
}
110+
}
111+
else if (!this.country.equals(other.country)) {
112+
return false;
113+
}
114+
if (this.description == null) {
115+
if (other.description != null) {
116+
return false;
117+
}
118+
}
119+
else if (!this.description.equals(other.description)) {
120+
return false;
121+
}
122+
if (this.fullname == null) {
123+
if (other.fullname != null) {
124+
return false;
125+
}
126+
}
127+
else if (!this.fullname.equals(other.fullname)) {
128+
return false;
129+
}
130+
if (this.lastname == null) {
131+
if (other.lastname != null) {
132+
return false;
133+
}
134+
}
135+
else if (!this.lastname.equals(other.lastname)) {
136+
return false;
137+
}
138+
return true;
139+
}
140+
141+
public int hashCode() {
142+
final int prime = 31;
143+
int result = 1;
144+
result = prime * result + ((this.company == null) ? 0 : this.company.hashCode());
145+
result = prime * result + ((this.country == null) ? 0 : this.country.hashCode());
146+
result = prime * result + ((this.description == null) ? 0 : this.description.hashCode());
147+
result = prime * result + ((this.fullname == null) ? 0 : this.fullname.hashCode());
148+
result = prime * result + ((this.lastname == null) ? 0 : this.lastname.hashCode());
149+
return result;
150+
}
151+
152+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2005-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.ldap.itest.transaction.compensating.manager.hibernate;
18+
19+
public interface OrgPersonDao {
20+
21+
void createWithException(OrgPerson person);
22+
23+
void create(OrgPerson person);
24+
25+
void update(OrgPerson person);
26+
27+
void updateWithException(OrgPerson person);
28+
29+
void updateAndRename(String dn, String newDn, String updatedDescription);
30+
31+
void updateAndRenameWithException(String dn, String newDn, String updatedDescription);
32+
33+
void modifyAttributes(String dn, String lastName, String description);
34+
35+
void modifyAttributesWithException(String dn, String lastName, String description);
36+
37+
void unbind(OrgPerson person);
38+
39+
void unbindWithException(OrgPerson person);
40+
41+
}

0 commit comments

Comments
 (0)