Examples of PresentException


Examples of com.k_int.IR.PresentException

        LOGGER.finer("search task = " + st);

        // Try and do a normal present
        try {
            if (start < 1) {
                throw new PresentException("Start record must be > 0", "13");
            }

            int numRecs = st.getTaskResultSet().getFragmentCount();

            LOGGER.finer("numresults = " + numRecs);

            int requestedNum = (start + count) - 1;

            if (requestedNum > numRecs) {
                count = numRecs - (start - 1);

                if (((start + count) - 1) > numRecs) {
                    LOGGER.finer(requestedNum + " < " + numRecs);
                    throw new PresentException("Start+Count-1 (" + requestedNum
                        + ") must be < the "
                        + " number of items in the result set: " + numRecs, "13");
                }
            }

            if (st == null) {
                throw new PresentException("Unable to locate result set", "30");
            }

            Vector v = new Vector();
            retval.which = Records_type.responserecords_CID;
            retval.o = v;

            OIDRegisterEntry requested_syntax = null;
            String requested_syntax_name = null;

            if (preferredRecordSyntax != null) {
                requested_syntax = reg.lookupByOID(preferredRecordSyntax);

                if (requested_syntax == null) { // unsupported record syntax

                    StringBuffer oid = new StringBuffer();

                    for (int i = 0; i < preferredRecordSyntax.length; i++) {
                        if (i != 0) {
                            oid.append('.');
                        }

                        oid.append(preferredRecordSyntax[i]);
                    }

                    LOGGER.warning("Unsupported preferredRecordSyntax="
                        + oid.toString());

                    // Need to set up diagnostic in here
                    retval.which = Records_type.nonsurrogatediagnostic_CID;

                    DefaultDiagFormat_type default_diag = new DefaultDiagFormat_type();
                    retval.o = default_diag;

                    default_diag.diagnosticSetId = reg.oidByName("diag-1");
                    default_diag.condition = BigInteger.valueOf(239);
                    default_diag.addinfo = new addinfo_inline14_type();
                    default_diag.addinfo.which = addinfo_inline14_type.v2addinfo_CID;
                    default_diag.addinfo.o = (Object) (oid.toString());

                    return retval;
                }

                LOGGER.finer("requested_syntax=" + requested_syntax);
                requested_syntax_name = requested_syntax.getName();

                if (requested_syntax_name.equals("usmarc")) {
                    //HACK!  USMARC not yet supported...
                    requested_syntax_name = "sutrs";
                }

                LOGGER.finer("requested_syntax_name=" + requested_syntax_name);
            } else {
                requested_syntax_name = "sutrs"; //REVISIT: should this be

                //default?  We're sure to have it...
                requested_syntax = reg.lookupByName(requested_syntax_name);
            }

            st.setRequestedSyntax(requested_syntax);
            st.setRequestedSyntaxName(requested_syntax_name);

            InformationFragment[] raw_records;
            RecordFormatSpecification rfSpec = new RecordFormatSpecification(requested_syntax_name,
                    null, recordFormatSetname);
            LOGGER.finer("calling getFragment(" + (start) + "," + count + ")");
            raw_records = st.getTaskResultSet().getFragment(start, count, rfSpec);

            if (raw_records == null) {
                throw new PresentException("Error retrieving records", "30");
            }

            for (int i = 0; i < raw_records.length; i++) {
                LOGGER.finer("Adding record " + i + " to result");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.