Skip to content

Commit 91a0db1

Browse files
committed
Merge branch 'release/ceridwen-standard-interchange-protocol-library-2.9.3'
2 parents 45f59c0 + d89a353 commit 91a0db1

27 files changed

+1225
-356
lines changed

CHANGELOG.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Version 2.9.3: 10/10/2016
2+
Update sample to use netty server
3+
Added SSL Socket client connection
4+
Updated Netty SSL server to load certificates
5+
Dependencies: ceridwen utilitiy 1.6.2
6+
apache commons beanutils 1.9.3
7+
apache commons lang 3.4
8+
apache commons logging 1.2
9+
apache commons net 3.5
10+
io.netty transport 4.1.5.Final
11+
io.netty handler 4.1.5.Final
12+
113
Version 2.9.2: 20/04/2016
214
Added netty server implementation
315
Added field ordering options (alphabetic or specification listed)

README.md

Lines changed: 125 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,126 @@
1-
## ceridwen-standard-interchange-protocol-library
1+
## Ceridwen 3M SIP Circulation Library for Java
22

3-
Java Implementation of the 3M SIP2 and NISO SIP3 Protocols for library circulation and self-check facilities.
3+
3M SIP is an industry standard protocol by 3M to allow automatec check out terminals communicate with library systems.
4+
5+
The Ceridwen 3M SIP Circulation Library for Java is an Open Source (GPL v3) implementation of the 3M SIP version 2 protocol (also known as SIP2). It includes both client and server implementations and support both telnet and socket based communications.
6+
7+
### Problems and Issues
8+
9+
For general problems please contact [development@ceridwen.com](mailto:development@ceridwen.com). For bugs and feature requests, please use our [online issue tracker]().
10+
11+
### License
12+
13+
The Ceridwen Self Issue Client is available as open source under [GPL v3](http://www.gnu.org/licenses/gpl.html). Contact [development@ceridwen.com](mailto:development@ceridwen.com) for other licensing options.
14+
15+
### Sample Application
16+
17+
The following hava code demonstrates the use of the library. It starts up a simple server implementation, and then uses the client API to check out a book.
18+
19+
```java
20+
public class Sample {
21+
22+
public static void main(String[] args) {
23+
try {
24+
System.setProperty("com.ceridwen.circulation.SIP.charset", "ISO8859_1");
25+
26+
SIPDaemon server;
27+
28+
// Run netty server
29+
server = new SIPDaemon("Sample", "localhost", 12345, false, new DummyDriverFactory(), true);
30+
server.start();
31+
32+
// Do sample checkout
33+
Sample.checkOut();
34+
35+
// Shut down netty server
36+
server.stop();
37+
} catch (Exception ex) {
38+
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
39+
}
40+
}
41+
42+
public static void checkOut() {
43+
/**
44+
* Now try basic client commands
45+
*/
46+
SocketConnection connection;
47+
48+
connection = new SocketConnection();
49+
connection.setHost("localhost");
50+
connection.setPort(12345);
51+
connection.setConnectionTimeout(30000);
52+
connection.setIdleTimeout(30000);
53+
connection.setRetryAttempts(2);
54+
connection.setRetryWait(500);
55+
56+
try {
57+
connection.connect();
58+
} catch (Exception ex) {
59+
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
60+
return;
61+
}
62+
63+
/**
64+
* It is necessary to send a SC Status with protocol version 2.0 else server
65+
* will assume 1.0)
66+
*/
67+
SCStatus scStatusRequest = new SCStatus();
68+
scStatusRequest.setProtocolVersion(ProtocolVersion.VERSION_2_00);
69+
70+
Message scStatusResponse;
71+
72+
try {
73+
scStatusResponse = connection.send(scStatusRequest);
74+
} catch (RetriesExceeded | ConnectionFailure | MessageNotUnderstood | ChecksumError | SequenceError | MandatoryFieldOmitted | InvalidFieldLength ex) {
75+
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
76+
return;
77+
}
78+
79+
if (!(scStatusResponse instanceof ACSStatus)) {
80+
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, "Error - Status Request did not return valid response from server.");
81+
return;
82+
}
83+
84+
/**
85+
* For debugging XML handling code (but could be useful in Cocoon)
86+
*/
87+
scStatusResponse.xmlEncode(System.out);
88+
89+
/**
90+
* Check if the server can support checkout
91+
*/
92+
if (!((ACSStatus) scStatusResponse).getSupportedMessages().isSet(SupportedMessages.CHECK_OUT)) {
93+
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, "Check out not supported");
94+
return;
95+
}
96+
97+
CheckOut checkOutRequest = new CheckOut();
98+
99+
/**
100+
* Now try a checkout request
101+
*/
102+
checkOutRequest.setPatronIdentifier("2000000");
103+
checkOutRequest.setItemIdentifier("300000000");
104+
checkOutRequest.setSCRenewalPolicy(Boolean.TRUE);
105+
checkOutRequest.setTransactionDate(new Date());
106+
107+
Message checkOutResponse;
108+
109+
try {
110+
checkOutResponse = connection.send(checkOutRequest);
111+
} catch (RetriesExceeded | ConnectionFailure | MessageNotUnderstood | ChecksumError | SequenceError | MandatoryFieldOmitted | InvalidFieldLength ex) {
112+
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
113+
return;
114+
}
115+
116+
if (!(checkOutResponse instanceof CheckOutResponse)) {
117+
Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, "Error - CheckOut Request did not return valid response from server");
118+
return;
119+
}
120+
checkOutResponse.xmlEncode(System.out);
121+
122+
connection.disconnect();
123+
}
124+
125+
}
126+
```

pom.xml

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<groupId>com.ceridwen.circulation</groupId>
2323
<artifactId>ceridwen-standard-interchange-protocol-library</artifactId>
24-
<version>2.9.2</version>
24+
<version>2.9.3</version>
2525
<packaging>jar</packaging>
2626

2727
<name>ceridwen-standard-interchange-protocol-library</name>
@@ -62,14 +62,27 @@
6262
<repository>
6363
<id>ceridwen-libs-release</id>
6464
<name>Ceridwen Release Repository</name>
65-
<url>https://software.ceridwen.com/artifactory/libs-release-local</url>
65+
<url>https://software.ceridwen.com/artifactory/libs-release</url>
6666
</repository>
6767
<repository>
6868
<id>ceridwen-libs-snapshot</id>
6969
<name>Ceridwen Snapshot Repository</name>
70-
<url>https://software.ceridwen.com/artifactory/libs-snapshot-local</url>
70+
<url>https://software.ceridwen.com/artifactory/libs-snapshot</url>
7171
</repository>
7272
</repositories>
73+
74+
<pluginRepositories>
75+
<pluginRepository>
76+
<id>ceridwen-plugins-release</id>
77+
<name>Ceridwen Release Plugin Repository</name>
78+
<url>https://software.ceridwen.com/artifactory/plugins-release</url>
79+
</pluginRepository>
80+
<pluginRepository>
81+
<id>ceridwen-plugins-snapshot</id>
82+
<name>Ceridwen Snapshot Plugin Repository</name>
83+
<url>https://software.ceridwen.com/artifactory/plugins-snapshot</url>
84+
</pluginRepository>
85+
</pluginRepositories>
7386

7487
<dependencies>
7588
<dependency>
@@ -90,32 +103,27 @@
90103
<dependency>
91104
<groupId>commons-net</groupId>
92105
<artifactId>commons-net</artifactId>
93-
<version>3.4</version>
106+
<version>3.5</version>
94107
</dependency>
95108
<dependency>
96109
<groupId>commons-logging</groupId>
97110
<artifactId>commons-logging</artifactId>
98111
<version>1.2</version>
99112
</dependency>
100-
<dependency>
101-
<groupId>commons-collections</groupId>
102-
<artifactId>commons-collections</artifactId>
103-
<version>3.2.2</version>
104-
</dependency>
105113
<dependency>
106114
<groupId>commons-beanutils</groupId>
107115
<artifactId>commons-beanutils</artifactId>
108-
<version>1.9.2</version>
116+
<version>1.9.3</version>
109117
</dependency>
110118
<dependency>
111119
<groupId>io.netty</groupId>
112120
<artifactId>netty-transport</artifactId>
113-
<version>4.0.36.Final</version>
121+
<version>4.1.5.Final</version>
114122
</dependency>
115123
<dependency>
116124
<groupId>io.netty</groupId>
117125
<artifactId>netty-handler</artifactId>
118-
<version>4.0.36.Final</version>
126+
<version>4.1.5.Final</version>
119127
</dependency>
120128
</dependencies>
121129

@@ -143,12 +151,17 @@
143151
<plugin>
144152
<groupId>org.apache.maven.plugins</groupId>
145153
<artifactId>maven-resources-plugin</artifactId>
146-
<version>2.7</version>
154+
<version>3.0.1</version>
147155
</plugin>
148156
<plugin>
149157
<groupId>org.apache.maven.plugins</groupId>
150158
<artifactId>maven-surefire-plugin</artifactId>
151159
<version>2.19.1</version>
160+
<configuration>
161+
<testSourceDirectory>${basedir}/src/main/java/</testSourceDirectory>
162+
<testClassesDirectory>${project.build.directory}/classes/</testClassesDirectory>
163+
<test>Message#</test>
164+
</configuration>
152165
</plugin>
153166
<plugin>
154167
<groupId>org.apache.maven.plugins</groupId>
@@ -158,7 +171,7 @@
158171
<plugin>
159172
<groupId>org.apache.maven.plugins</groupId>
160173
<artifactId>maven-jar-plugin</artifactId>
161-
<version>2.6</version>
174+
<version>3.0.2</version>
162175
<configuration>
163176
<archive>
164177
<manifest>
@@ -180,17 +193,17 @@
180193
<plugin>
181194
<groupId>org.apache.maven.plugins</groupId>
182195
<artifactId>maven-war-plugin</artifactId>
183-
<version>2.6</version>
196+
<version>3.0.0</version>
184197
</plugin>
185198
<plugin>
186199
<groupId>org.apache.maven.plugins</groupId>
187200
<artifactId>maven-javadoc-plugin</artifactId>
188-
<version>2.10.3</version>
201+
<version>2.10.4</version>
189202
</plugin>
190203
<plugin>
191204
<groupId>org.apache.maven.plugins</groupId>
192205
<artifactId>maven-source-plugin</artifactId>
193-
<version>3.0.0</version>
206+
<version>3.0.1</version>
194207
</plugin>
195208
<plugin>
196209
<groupId>org.apache.maven.plugins</groupId>
@@ -215,15 +228,15 @@
215228
<plugin>
216229
<groupId>org.codehaus.mojo</groupId>
217230
<artifactId>versions-maven-plugin</artifactId>
218-
<version>2.2</version>
231+
<version>2.3</version>
219232
</plugin>
220233
</plugins>
221234
</pluginManagement>
222235
<plugins>
223236
<plugin>
224237
<groupId>external.atlassian.jgitflow</groupId>
225238
<artifactId>jgitflow-maven-plugin</artifactId>
226-
<version>1.0-m5.1</version>
239+
<version>1.0.0-mjf_276-SNAPSHOT</version>
227240
<configuration>
228241
<flowInitContext>
229242
<masterBranchName>master</masterBranchName>

src/main/java/com/ceridwen/circulation/SIP/exceptions/MessageNotUnderstood.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ public class MessageNotUnderstood extends Exception {
2525
private static final long serialVersionUID = 1857825095575274480L;
2626

2727
public MessageNotUnderstood() {
28+
super();
29+
}
30+
31+
public MessageNotUnderstood(Throwable ex) {
32+
super(ex);
2833
}
2934
}

src/main/java/com/ceridwen/circulation/SIP/exceptions/RetriesExceeded.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,10 @@ public class RetriesExceeded extends Exception {
3434
private static final long serialVersionUID = 1416841113916472161L;
3535

3636
public RetriesExceeded() {
37+
super();
38+
}
39+
40+
public RetriesExceeded(Throwable ex) {
41+
super(ex);
3742
}
3843
}

src/main/java/com/ceridwen/circulation/SIP/fields/Fields.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ static public PositionedFieldDefinition getPositionedFieldDefinition(String mess
247247
} catch (Exception ex) {
248248
throw new java.lang.AssertionError(messageName + " - Positioned FieldDescriptor not defined: " + fieldName);
249249
}
250-
if (fld == null) {
251-
throw new java.lang.AssertionError(messageName + " - Positioned FieldDescriptor not defined: " + fieldName);
252-
}
250+
// if (fld == null) {
251+
// throw new java.lang.AssertionError(messageName + " - Positioned FieldDescriptor not defined: " + fieldName);
252+
// }
253253
Field fldann = fld.getAnnotation(Field.class);
254254
if (fldann == null) {
255255
throw new java.lang.AssertionError(messageName + " - Positioned FieldDescriptor not defined: " + fieldName);
@@ -273,9 +273,9 @@ static public TaggedFieldDefinition getTaggedFieldDefinition(String messageName,
273273
} catch (Exception ex) {
274274
throw new java.lang.AssertionError(messageName + " - Tagged FieldDescriptor not defined: " + fieldName);
275275
}
276-
if (fld == null) {
277-
throw new java.lang.AssertionError(messageName + " - Tagged FieldDescriptor not defined: " + fieldName);
278-
}
276+
// if (fld == null) {
277+
// throw new java.lang.AssertionError(messageName + " - Tagged FieldDescriptor not defined: " + fieldName);
278+
// }
279279
Field fldann = fld.getAnnotation(Field.class);
280280
if (fldann == null) {
281281
throw new java.lang.AssertionError(messageName + " - Tagged FieldDescriptor not defined: " + fieldName);

src/main/java/com/ceridwen/circulation/SIP/messages/ItemInformationResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
import com.ceridwen.circulation.SIP.types.enumerations.SecurityMarker;
4343

4444
@Command("18")
45-
@TestCaseDefault("1801000119700101 010000AB|AJ|")
46-
@TestCasePopulated("1813030919700101 010000ABitemIdentifier|AFscreenMessage|AGprintLine|AHdueDate|AJtitleIdentifier|APcurrentLocation|AQpermanentLocation|BGowner|BHGBP|BVfeeAmount|CF123456789|CHitemProperties|CJ19700101 010000|CK010|CM19700101 010000|")
45+
@TestCaseDefault("1801000119700101 010000AB|AJ|CF00000|")
46+
@TestCasePopulated("1813030919700101 010000ABitemIdentifier|AFscreenMessage|AGprintLine|AHdueDate|AJtitleIdentifier|APcurrentLocation|AQpermanentLocation|BGowner|BHGBP|BVfeeAmount|CF12345|CHitemProperties|CJ19700101 010000|CK010|CM19700101 010000|")
4747
public class ItemInformationResponse extends Message {
4848
private static final long serialVersionUID = 6408854778106704492L;
4949
@PositionedField(start = 2, end = 3)

src/main/java/com/ceridwen/circulation/SIP/messages/Message.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private String encode(Character sequence, boolean autoPop) throws MandatoryField
327327
desc.getPropertyType().getName());
328328
}
329329
}
330-
if (fixed.containsKey(new Integer(field.start))) {
330+
if (fixed.containsKey(Integer.valueOf(field.start))) {
331331
throw new java.lang.AssertionError("Positioning error inserting field at " + field.start + " for class " + this.getClass().getName());
332332
}
333333
fixed.put(new Integer(field.start), this.pad(value[0], field));
@@ -411,7 +411,7 @@ private void setProp(PropertyDescriptor desc, String value) {
411411
if (desc.getPropertyType() == Integer.class) {
412412
if (!value.trim().isEmpty()) {
413413
desc.getWriteMethod().invoke(this,
414-
new Object[] { new Integer(value.trim()) });
414+
new Object[] {Integer.valueOf(value.trim()) });
415415
}
416416
return;
417417
}
@@ -684,13 +684,11 @@ public void xmlEncode(OutputStream strm) {
684684
XMLEncoder out = new XMLEncoder(strm);
685685
out.writeObject(this);
686686
out.flush();
687-
out.close();
688687
}
689688

690689
public static Message xmlDecode(InputStream strm) {
691690
XMLDecoder in = new XMLDecoder(strm);
692691
Message msg = (Message) in.readObject();
693-
in.close();
694692
return msg;
695693
}
696694

@@ -808,7 +806,7 @@ private Message getDefaultMessage() {
808806
if (field.getType() == Integer.class) {
809807
Method method = desc.getWriteMethod();
810808
if (method != null) {
811-
method.invoke(msg, new Object[]{new Integer(0)});
809+
method.invoke(msg, new Object[]{Integer.valueOf(0)});
812810
}
813811
}
814812
if (field.getType() == Boolean.class) {
@@ -878,7 +876,7 @@ private Message getPopulatedMessage() {
878876
if (length != 0) {
879877
value = value.substring(0, length);
880878
}
881-
method.invoke(msg, new Object[]{new Integer(value)});
879+
method.invoke(msg, new Object[]{Integer.valueOf(value)});
882880
}
883881
if (type == String.class) {
884882
String value = field.getName();

0 commit comments

Comments
 (0)