Giter Club home page Giter Club logo

sudhish74 / ceridwen-standard-interchange-protocol-library Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ceridwen-com/ceridwen-standard-interchange-protocol-library

0.0 1.0 0.0 3.84 MB

Java Implementation of the 3M SIP2 and NISO SIP3 Protocols for library self-check applications

Home Page: https://software.ceridwen.com/redmine/projects/ceridwen-standard-interchange-protocol-library/

License: GNU General Public License v3.0

Java 100.00%

ceridwen-standard-interchange-protocol-library's Introduction

Ceridwen 3M SIP Circulation Library for Java

3M SIP is an industry standard protocol by 3M to allow automatec check out terminals communicate with library systems.

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.

Problems and Issues

For general problems please contact [email protected]. For bugs and feature requests, please use our online issue tracker.

License

The Ceridwen Self Issue Client is available as open source under GPL v3. Contact [email protected] for other licensing options.

Sample Application

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.

public class Sample {

  public static void main(String[] args) {
    try {
      System.setProperty("com.ceridwen.circulation.SIP.charset", "ISO8859_1");

      SIPDaemon server;

      // Run netty server
      server = new SIPDaemon("Sample", "localhost", 12345, false, new DummyDriverFactory(), true);
      server.start();

      // Do sample checkout
      Sample.checkOut();

      // Shut down netty server
      server.stop();
    } catch (Exception ex) {
      Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
    }
  }

  public static void checkOut() {
    /**
     * Now try basic client commands
     */
    SocketConnection connection;

    connection = new SocketConnection();
    connection.setHost("localhost");
    connection.setPort(12345);
    connection.setConnectionTimeout(30000);
    connection.setIdleTimeout(30000);
    connection.setRetryAttempts(2);
    connection.setRetryWait(500);

    try {
      connection.connect();
    } catch (Exception ex) {
      Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
      return;
    }

    /**
     * It is necessary to send a SC Status with protocol version 2.0 else server
     * will assume 1.0)
     */
    SCStatus scStatusRequest = new SCStatus();
    scStatusRequest.setProtocolVersion(ProtocolVersion.VERSION_2_00);

    Message scStatusResponse;

    try {
      scStatusResponse = connection.send(scStatusRequest);
    } catch (RetriesExceeded | ConnectionFailure | MessageNotUnderstood | ChecksumError | SequenceError | MandatoryFieldOmitted | InvalidFieldLength ex) {
      Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
      return;
    }

    if (!(scStatusResponse instanceof ACSStatus)) {
      Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, "Error - Status Request did not return valid response from server.");
      return;
    }

    /**
     * For debugging XML handling code (but could be useful in Cocoon)
     */
    scStatusResponse.xmlEncode(System.out);

    /**
     * Check if the server can support checkout
     */
    if (!((ACSStatus) scStatusResponse).getSupportedMessages().isSet(SupportedMessages.CHECK_OUT)) {
      Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, "Check out not supported");
      return;
    }

    CheckOut checkOutRequest = new CheckOut();

    /**
     * Now try a checkout request
     */
    checkOutRequest.setPatronIdentifier("2000000");
    checkOutRequest.setItemIdentifier("300000000");
    checkOutRequest.setSCRenewalPolicy(Boolean.TRUE);
    checkOutRequest.setTransactionDate(new Date());

    Message checkOutResponse;

    try {
      checkOutResponse = connection.send(checkOutRequest);
    } catch (RetriesExceeded | ConnectionFailure | MessageNotUnderstood | ChecksumError | SequenceError | MandatoryFieldOmitted | InvalidFieldLength ex) {
      Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, null, ex);
      return;
    }

    if (!(checkOutResponse instanceof CheckOutResponse)) {
      Logger.getLogger(Sample.class.getName()).log(Level.SEVERE, "Error - CheckOut Request did not return valid response from server");
      return;
    }
    checkOutResponse.xmlEncode(System.out);

    connection.disconnect();
  }

}

ceridwen-standard-interchange-protocol-library's People

Contributors

mdovey avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.