Open-ILS/src/extras/Makefile
Open-ILS/src/extras/Makefile.in
Open-ILS/src/extras/oils_requestor
-Open-ILS/src/java/Makefile
-Open-ILS/src/java/Makefile.in
Open-ILS/src/Makefile
Open-ILS/src/Makefile.in
Open-ILS/src/perlmods/blib/
endif
#------------------------------
-# Build EVERGREEN JAVA
-#------------------------------
-
-if BUILDEGJAVA
-OILSJAVA_DIR = java
-endif
# scripts that are generated from *.in files and can
# be deleted by a make clean
# Take care of which subdirectories to build, and which extra files to include in a distribution.
-SUBDIRS = $(OILSCORE_DIRS) $(OILSWEB_DIR) $(OILSJAVA_DIR)
+SUBDIRS = $(OILSCORE_DIRS) $(OILSWEB_DIR)
EXTRA_DIST = @srcdir@/perlmods \
@srcdir@/data \
+++ /dev/null
-JAVA_LIBDIR = .lib
-JAVAC = javac -J-Xmx256m
-JAVA = java -Xmx256m
-OSRF_HOME = ../../../../OpenSRF/src/java
-OSRFJAVA = $(OSRF_HOME)/opensrf.jar
-EXT = $(OSRF_HOME)/deps
-JAVA_LIBS = .:$(JAVA_LIBDIR):$(OSRFJAVA):$(EXT)/json.jar:$(EXT)/java_memcached-release_2.0.1.jar
-JAVA_SRC = \
- org/open_ils/*.java\
- org/open_ils/idl/*.java\
- org/open_ils/util/*.java\
- org/open_ils/test/*.java
-
-all-local: jar
-
-jar:
- $(MKDIR_P) $(JAVA_LIBDIR)
- $(JAVAC) -d $(JAVA_LIBDIR) -cp $(JAVA_LIBS) $(JAVA_SRC) 2>&1
- rm -f openils.jar
- echo "creating openils.jar"
- jar cf openils.jar -C .lib org
-
-
-# only prints the first 30 lines of errors
-slim:
- $(MKDIR_P) $(JAVA_LIBDIR)
- $(JAVAC) -d $(JAVA_LIBDIR) -cp $(JAVA_LIBS) $(JAVA_SRC) 2>&1 | head -n 30
- @echo -e "\nTruncating at 30 lines"
-
-check:
- $(MKDIR_P) $(JAVA_LIBDIR)
- $(JAVAC) -Xlint:unchecked -d $(JAVA_LIBDIR) -cp $(JAVA_LIBS) $(JAVA_SRC) 2>&1 | head -n 30
- @echo -e "\nTruncating at 30 lines"
-
-run:
- @$(JAVA) -cp $(JAVA_LIBS):openils.jar $(JAVA_EXE) $(JAVA_ARGS)
-
-deps:
- $(MKDIR_P) ext
-
-docs:
- find . -name *.java > files;
- javadoc -classpath $(JAVA_LIBS) -d doc @files;
- rm files;
-
-clean:
- rm -r $(JAVA_LIBDIR)
-
-
+++ /dev/null
-package org.open_ils;
-
-import java.util.Map;
-import java.util.HashMap;
-
-public class Event extends HashMap<String, Object> {
-
- public Event() {
- }
-
- public Event(Map<String, Object> map) {
- super(map);
- }
-
- public static Event parseEvent(Object map) {
- if( map != null && map instanceof Map) {
- Map m = (Map) map;
- if( m.containsKey("ilsevent") && m.containsKey("textcode"))
- return new Event(m);
- }
-
- return null;
- }
-
- public String getTextCode() {
- return (String) get("textcode");
- }
-
- public int getCode() {
- return Integer.parseInt((String) get("ilsevent"));
- }
-}
-
+++ /dev/null
-package org.open_ils;
-
-import org.opensrf.*;
-import org.opensrf.util.*;
-import org.open_ils.*;
-import org.open_ils.idl.*;
-import org.opensrf.util.*;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.io.IOException;
-
-
-public class Sys {
-
- private static IDLParser idlParser = null;
-
- /**
- * Initializes the connection to the OpenSRF network and parses the IDL file.
- * @param attrs A map of configuration attributes. Options include:<br/>
- * <ul>
- * <li>configFile - The OpenSRF core config file</li>
- * <li>configContext - The path to the config chunk in the config XML, typically "opensrf"</li>
- * <li>logProtocol - Currently supported option is "file".</li>
- * <li>logLevel - The log level. Options are 1,2,3, or 4 (error, warn, info, debug)</li>
- * <li>syslogFacility - For future use, when syslog is a supported log option</li>
- * <li>idlFile - The path to the IDL file. May be relative or absolute. If this option is
- * not provided, the system will ask the OpenSRF Settings server for the IDL file path.</li>
- * </ul>
- */
- public static void init(Map<String, String> attrs) throws ConfigException, SessionException, IOException, IDLException {
-
- String configFile = attrs.get("configFile");
- String configContext = attrs.get("configContext");
- String logProto = attrs.get("logProtocol");
- String logFile = attrs.get("logFile");
- String logLevel = attrs.get("logLevel");
- String syslogFacility = attrs.get("syslogFacility");
- String idlFile = attrs.get("idlFile");
-
-
- if(idlParser != null) {
- /** if we've parsed the IDL file, then all of the global setup has been done.
- * We just need to verify this thread is connected to the OpenSRF network. */
- org.opensrf.Sys.bootstrapClient(configFile, configContext);
- return;
- }
-
- /** initialize the logging infrastructure */
- if("file".equals(logProto))
- Logger.init(Short.parseShort(logLevel), new FileLogger(logFile));
-
- if("syslog".equals(logProto))
- throw new ConfigException("syslog not yet implemented");
-
- /** connect to the opensrf network. */
- org.opensrf.Sys.bootstrapClient(configFile, configContext);
-
- /** Grab the IDL file setting if not explicitly provided */
- if(idlFile == null) {
- SettingsClient client = SettingsClient.instance();
- idlFile = client.getString("/IDL");
- }
-
- /** Parse the IDL if necessary */
- idlParser = new IDLParser(idlFile);
- idlParser.parse();
- }
-}
-
+++ /dev/null
-package org.open_ils.idl;
-
-public class IDLException extends Exception {
- public IDLException(String info) {
- super(info);
- }
- public IDLException(String info, Throwable cause) {
- super(info, cause);
- }
-}
+++ /dev/null
-package org.open_ils.idl;
-
-public class IDLField {
-
- /** Field name */
- private String name;
-
- /** Where this field resides in the array when serilized */
- private int arrayPos;
-
- /** True if this field does not belong in the database */
- private boolean isVirtual;
-
- public void setName(String name) {
- this.name = name;
- }
- public void setArrayPos(int arrayPos) {
- this.arrayPos = arrayPos;
- }
- public void setIsVirtual(boolean isVirtual) {
- this.isVirtual = isVirtual;
- }
- public String getName() {
- return this.name;
- }
- public int getArrayPos() {
- return this.arrayPos;
- }
- public boolean getIsVirtual() {
- return this.isVirtual;
- }
-
- public void toXML(StringBuffer sb) {
- sb.append("\t\t\t<field name='");
- sb.append(name);
- sb.append("' ");
- sb.append(IDLParser.OILS_NS_OBJ_PREFIX);
- sb.append(":array_position='");
- sb.append(arrayPos);
- sb.append("' ");
- sb.append(IDLParser.OILS_NS_PERSIST_PREFIX);
- sb.append(":virtual='");
- sb.append(isVirtual);
- sb.append("'/>\n");
- }
-}
+++ /dev/null
-package org.open_ils.idl;
-
-
-public class IDLLink {
-
- /**The field on the IDLObject this link extends from */
- private String field;
- private String reltype;
- private String key;
- private String map;
- /**The IDL class linked to */
- private String IDLClass;
-
-
- public void setField(String field) {
- this.field = field;
- }
- public void setReltype(String reltype) {
- this.reltype = reltype;
- }
- public void setKey(String key) {
- this.key = key;
- }
- public void setMap(String map) {
- this.map = map;
- }
- public void setIDLClass(String IDLClass) {
- this.IDLClass = IDLClass;
- }
- public String getField() {
- return this.field;
- }
- public String getReltype() {
- return this.reltype;
- }
- public String getKey() {
- return this.key;
- }
- public String getMap() {
- return this.map;
- }
- public String getIDLClass() {
- return this.IDLClass;
- }
-}
-
+++ /dev/null
-package org.open_ils.idl;
-import java.util.HashMap;
-import java.util.Iterator;
-
-
-public class IDLObject {
-
- private String IDLClass;
- private String fieldMapper;
- private String controller;
- private String rptLabel;
- private HashMap<String, IDLField> fields;
- private HashMap<String, IDLLink> links;
-
- /** true if this is a virtual object (does not live in the database) */
- private boolean isVirtual;
-
- public IDLObject() {
- fields = new HashMap<String, IDLField>();
- links = new HashMap<String, IDLLink>();
- }
-
- public String getIDLClass() {
- return IDLClass;
- }
-
- public void addLink(IDLLink link) {
- links.put(link.getField(), link);
- }
-
- public void addField(IDLField field) {
- fields.put(field.getName(), field);
- }
-
- public IDLField getField(String name) {
- return (IDLField) fields.get(name);
- }
-
- public HashMap getFields() {
- return fields;
- }
-
-
- /**
- * Returns the link object found at the given field on
- * this IDLObject.
- */
- public IDLLink getLink(String fieldName) {
- return (IDLLink) links.get(fieldName);
- }
-
- public String getFieldMapper() {
- return fieldMapper;
- }
-
- public String getController() {
- return controller;
- }
-
- public String getRptLabel() {
- return rptLabel;
- }
- public boolean isVirtual() {
- return isVirtual;
- }
-
- public void setIDLClass(String IDLClass) {
- this.IDLClass = IDLClass;
- }
-
- public void setFieldMapper(String fm) {
- this.fieldMapper = fm;
- }
- public void setController(String controller) {
- this.controller = controller;
- }
- public void setRptLabel(String label) {
- this.rptLabel = label;
- }
- public void setIsVirtual(boolean isVirtual) {
- this.isVirtual = isVirtual;
- }
-
-
- public void toXML(StringBuffer sb) {
-
- sb.append("\t\t<fields>");
- Iterator itr = fields.keySet().iterator();
- IDLField field;
- while(itr.hasNext()) {
- field = fields.get((String) itr.next());
- field.toXML(sb);
- }
- sb.append("\t\t</fields>");
- }
-}
+++ /dev/null
-package org.open_ils.idl;
-
-import org.opensrf.util.*;
-
-import java.util.HashMap;
-import java.util.Set;
-import java.util.Iterator;
-
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import javax.xml.stream.*;
-import javax.xml.stream.events.* ;
-import javax.xml.namespace.QName;
-
-
-public class IDLParser {
-
- public static final String OILS_NS_BASE="http://opensrf.org/spec/IDL/base/v1";
- public static final String OILS_NS_OBJ="http://open-ils.org/spec/opensrf/IDL/objects/v1";
- public static final String OILS_NS_OBJ_PREFIX="oils_obj";
- public static final String OILS_NS_PERSIST="http://open-ils.org/spec/opensrf/IDL/persistence/v1";
- public static final String OILS_NS_PERSIST_PREFIX="oils_persist";
- public static final String OILS_NS_REPORTER="http://open-ils.org/spec/opensrf/IDL/reporter/v1";
- public static final String OILS_NS_REPORTER_PREFIX="reporter";
-
- /** The source for the IDL XML */
- InputStream inStream;
- HashMap<String, IDLObject> IDLObjects;
- IDLObject current;
- private int fieldIndex;
-
- /** If true, we retain the full set of IDL objects in memory. This is true by default. */
- private boolean keepIDLObjects;
-
- private int parsedObjectCount;
-
- public IDLParser() {
- IDLObjects = new HashMap<String, IDLObject>();
- keepIDLObjects = true;
- parsedObjectCount = 0;
- fieldIndex = 0;
- }
-
- public IDLParser(String fileName) throws IOException {
- this(new FileInputStream(fileName));
- }
-
- public IDLParser(InputStream inStream) {
- this();
- this.inStream = inStream;
- }
-
-
- /**
- * Parses the IDL XML
- */
- public void parse() throws IOException, IDLException {
-
- try {
- XMLInputFactory factory = XMLInputFactory.newInstance();
-
- /** disable as many unused features as possible to speed up the parsing */
- factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
- factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
- factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
- factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
- factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
-
-
- /** create the stream reader */
- XMLStreamReader reader = factory.createXMLStreamReader(this.inStream);
- int eventType;
-
- while(reader.hasNext()) {
- /** cycle through the XML events */
-
- eventType = reader.next();
-
- switch(eventType) {
-
- case XMLEvent.START_ELEMENT:
- handleStartElement(reader);
- break;
-
- case XMLEvent.END_ELEMENT:
- handleEndElement(reader);
- break;
- }
- }
-
- } catch(javax.xml.stream.XMLStreamException se) {
- throw new IDLException("Error parsing IDL XML", se);
- }
- }
-
- /**
- * Returns the IDLObject with the given IDLClass
- */
- public IDLObject getObject(String IDLClass) {
- return (IDLObject) IDLObjects.get(IDLClass);
- }
-
- /**
- * Returns the full set of IDL objects as a hash from classname to object.
- * If keepIDLObjects is false, the map will be empty.
- */
- public HashMap<String, IDLObject> getIDLObjects() {
- return IDLObjects;
- }
-
- /**
- * Returns the number of parsed objects, regardless of the keepIDLObjects setting.
- */
- public int getObjectCount() {
- return parsedObjectCount;
- }
-
-
- public void handleStartElement(XMLStreamReader reader) {
-
- if(!OILS_NS_BASE.equals(reader.getNamespaceURI())) return;
- String localpart = reader.getLocalName();
-
- if( "class".equals(localpart) ) {
- fieldIndex = 0;
- current = new IDLObject();
- current.setIDLClass(reader.getAttributeValue(null, "id"));
- current.setController(reader.getAttributeValue(null, "controller"));
- String persist = reader.getAttributeValue(OILS_NS_PERSIST, "virtual");
- current.setIsVirtual("persist".equals(reader.getAttributeValue(OILS_NS_PERSIST, "virtual")));
- return;
- }
-
- if( "field".equals(localpart) ) {
- IDLField field = new IDLField();
- field.setName(reader.getAttributeValue(null, "name"));
- field.setArrayPos(fieldIndex++);
- field.setIsVirtual("true".equals(reader.getAttributeValue(OILS_NS_PERSIST, "virtual")));
- current.addField(field);
- }
-
- if( "link".equals(localpart) ) {
- IDLLink link = new IDLLink();
- link.setField(reader.getAttributeValue(null, "field"));
- link.setReltype(reader.getAttributeValue(null, "reltype"));
- link.setKey(reader.getAttributeValue(null, "key"));
- link.setMap(reader.getAttributeValue(null, "map"));
- link.setIDLClass(reader.getAttributeValue(null, "class"));
- current.addLink(link);
- }
- }
-
- public void handleEndElement(XMLStreamReader reader) throws IDLException {
-
- if(!OILS_NS_BASE.equals(reader.getNamespaceURI())) return;
- String localpart = reader.getLocalName();
-
- if("class".equals(localpart)) {
-
- String[] vfields = {"isnew", "ischanged", "isdeleted"};
- for (String fieldName : vfields) {
- IDLField field = new IDLField();
- field.setName(fieldName);
- field.setArrayPos(fieldIndex++);
- field.setIsVirtual(true);
- current.addField(field);
- }
-
- if(keepIDLObjects)
- IDLObjects.put(current.getIDLClass(), current);
-
- HashMap fields = current.getFields();
- String fieldNames[] = new String[fields.size()];
-
- for(Iterator itr = fields.keySet().iterator(); itr.hasNext(); ) {
- String key = (String) itr.next();
- IDLField field = (IDLField) fields.get(key);
- try {
- fieldNames[ field.getArrayPos() ] = field.getName();
- } catch(ArrayIndexOutOfBoundsException E) {
- String msg = "class="+current.getIDLClass()+";field="+key+
- ";fieldcount="+fields.size()+";currentpos="+field.getArrayPos();
- throw new IDLException(msg, E);
- }
- }
-
- OSRFRegistry.registerObject(
- current.getIDLClass(), OSRFRegistry.WireProtocol.ARRAY, fieldNames);
-
- parsedObjectCount++;
-
- current = null;
- }
- }
-
-
- public String toXML() {
- StringBuffer sb = new StringBuffer();
- Set keys = IDLObjects.keySet();
- Iterator itr = IDLObjects.keySet().iterator();
- String IDLClass;
- IDLObject obj;
- while(itr.hasNext()) {
- IDLClass = (String) itr.next();
- obj = IDLObjects.get(IDLClass);
- obj.toXML(sb);
- }
- return sb.toString();
- }
-}
-
-
-
-
-
-
+++ /dev/null
-package org.open_ils.test;
-import org.open_ils.idl.*;
-import org.opensrf.*;
-import org.opensrf.util.*;
-
-public class TestIDL {
- public static void main(String args[]) throws Exception {
- String idlFile = args[0];
- IDLParser parser = new IDLParser(idlFile);
- parser.parse();
- //System.out.print(parser.toXML());
-
- OSRFObject bre = new OSRFObject("bre");
- bre.put("id", new Integer(1));
- bre.put("isnew", new Boolean(false));
- bre.put("isdeleted", new Boolean(true));
- System.out.println(bre);
- System.out.println(new JSONWriter(bre).write());
- }
-}
+++ /dev/null
-package org.open_ils.test;
-import org.open_ils.util.Utils;
-import org.open_ils.Event;
-import org.opensrf.*;
-import java.util.Map;
-import java.util.HashMap;
-
-
-public class TestLogin {
- public static void main(String args[]) {
- try {
-
- if(args.length < 3) {
- System.err.println("usage: java org.open_ils.test.TestLogin <opensrf_config> <username> <password>");
- return;
- }
-
- Sys.bootstrapClient(args[0], "/config/opensrf");
- Map<String,String> params = new HashMap<String,String>();
- params.put("username", args[1]);
- params.put("password", args[2]);
- Event evt = Utils.login(params);
- System.out.println(evt);
- } catch(Exception e) {
- System.err.println(e);
- }
- }
-}
-
+++ /dev/null
-package org.open_ils.util;
-import org.open_ils.*;
-import org.opensrf.*;
-import org.opensrf.util.*;
-import java.util.Map;
-import java.util.HashMap;
-import java.security.MessageDigest;
-
-public class Utils {
-
- /**
- * Logs in.
- * @param params Login arguments, which may consist of<br/>
- * username<br/>
- * barcode - if username is provided, barcode will be ignored<br/>
- * password<br/>
- * workstation - name of the workstation where the login is occuring<br/>
- * type - type of login, currently "opac", "staff", and "temp"<br/>
- * org - optional org ID to provide login context when no workstation is used.
- * @return An Event object. On success, the event 'payload' will contain
- * 'authtoken' and 'authtime' fields, which represent the session key and
- * session inactivity timeout, respectively.
- */
- public static Event login(Map params) throws MethodException {
-
- Map<String, String> initMap = new HashMap<String, String>();
- String init = (params.get("username") != null) ?
- params.get("username").toString() : params.get("barcode").toString();
-
- Object resp = ClientSession.atomicRequest(
- "open-ils.auth",
- "open-ils.auth.authenticate.init", new Object [] {init});
-
- /** see if the server responded with some type of unexpected event */
- Event evt = Event.parseEvent(resp);
- if(evt != null) return evt;
-
- params.put("password", md5Hex(resp + md5Hex(params.get("password").toString())));
-
- resp = ClientSession.atomicRequest(
- "open-ils.auth",
- "open-ils.auth.authenticate.complete", new Object[]{params});
-
- return Event.parseEvent(resp);
- }
-
-
- /**
- * Generates the hex md5sum of a string.
- * @param s The string to md5sum
- * @return The 32-character hex md5sum
- */
- public static String md5Hex(String s) {
- StringBuffer sb = new StringBuffer();
- MessageDigest md;
- try {
- md = MessageDigest.getInstance("MD5");
- } catch(Exception e) {
- return null;
- }
-
- md.update(s.getBytes());
- byte[] digest = md.digest();
- for (int i = 0; i < digest.length; i++) {
- int b = digest[i] & 0xff;
- String hex = Integer.toHexString(b);
- if (hex.length() == 1) sb.append("0");
- sb.append(hex);
- }
- return sb.toString();
- }
-}
-
-
-
AM_CONDITIONAL([BUILDILSCLIENT], [test x$openils_client = xtrue])
-# build evergreen java ?
-
-AC_ARG_ENABLE([java],
-[ --enable-java enables installation of the Evergreen Java components ],
-[case "${enableval}" in
- yes) evergreen_java=true ;;
- no) evergreen_java=false ;;
- *) AC_MSG_ERROR([please choose another value for --enable-java (supported values are yes or no])
-esac],
-[evergreen_java=false])
-
-AM_CONDITIONAL([BUILDEGJAVA], [test x$evergreen_java = xtrue])
-
-
#-----------------------------------
# Check for dependencies
#-----------------------------------
AC_CONFIG_FILES([Open-ILS/examples/Makefile
Open-ILS/src/c-apps/Makefile
Open-ILS/src/c-apps/tests/Makefile
- Open-ILS/src/extras/Makefile
- Open-ILS/src/java/Makefile])
+ Open-ILS/src/extras/Makefile])
fi
if test "x$build_apachemods" = "xtrue"; then
else
AC_MSG_RESULT([Evergreen Staff Client: no])
fi
- if test "$evergreen_java" = "true" ; then
-AC_MSG_RESULT([Evergreen Java Components: yes])
- else
-AC_MSG_RESULT([Evergreen Java Components: no])
-fi
AC_MSG_RESULT([])
AC_MSG_RESULT([-------- Installation Directories --------])
AC_MSG_RESULT(Installation directory prefix: ${prefix})
In practice, OpenSRF includes convenience libraries in all of its client
language bindings to simplify access to configuration values. C offers
-osrfConfig.c, Perl offers `OpenSRF::Utils::SettingsClient`, Java offers
-`org.opensrf.util.SettingsClient`, and Python offers `osrf.set`. These
-libraries locally cache the configuration file to avoid network roundtrips for
-every request and enable the developer to request specific values without
-having to manually construct XPath expressions.
+osrfConfig.c, Perl offers `OpenSRF::Utils::SettingsClient`, and Python offers
+`osrf.set`. These libraries locally cache the configuration file to avoid
+network roundtrips for every request and enable the developer to request
+specific values without having to manually construct XPath expressions.
== Getting under the covers with OpenSRF ==
Now that you have seen that it truly is easy to create an OpenSRF service, we