Package com.k_int.gen.Z39_50_APDU_1995

Examples of com.k_int.gen.Z39_50_APDU_1995.PDU_type


                        + 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");

                NamePlusRecord_type npr = new NamePlusRecord_type();
                npr.name = raw_records[i].getSourceCollectionName();
                npr.record = new record_inline13_type();
                npr.record.which = record_inline13_type.retrievalrecord_CID;

                EXTERNAL_type rec = new EXTERNAL_type();
                npr.record.o = rec;

                if (requested_syntax_name.equals(Z3950Constants.RECSYN_HTML)
                        || requested_syntax_name.equals("sgml")) {
                    LOGGER.finer("Returning OctetAligned record for "
                        + requested_syntax_name);
                    rec.direct_reference = reg.oidByName(requested_syntax_name);
                    rec.encoding = new encoding_inline0_type();
                    rec.encoding.which = encoding_inline0_type.octet_aligned_CID;

                    String raw_string = (String) raw_records[i]
                        .getOriginalObject();
                    rec.encoding.o = raw_string.getBytes();

                    if (raw_string.length() == 0) {
                        // can't make a html record
                        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(227);
                        default_diag.addinfo = new addinfo_inline14_type();
                        default_diag.addinfo.which = addinfo_inline14_type.v2addinfo_CID;
                        default_diag.addinfo.o = (Object) "1.2.840.10003.5.109.3";

                        return retval;
                    }
                } else if (requested_syntax_name.equals(
                            Z3950Constants.RECSYN_XML)) {
                    // Since XML is our canonical internal schema,
                    //all realisations of InformationFragment
                    // are capable of providing an XML representation of
                    //themselves, so just use the
                    // Fragments getDocument method.
                    LOGGER.finer("Returning OctetAligned XML");

                    java.io.StringWriter sw = new java.io.StringWriter();

                    try {
                        OutputFormat format = new OutputFormat(raw_records[i]
                                .getDocument());
                        XMLSerializer serial = new XMLSerializer(sw, format);
                        serial.asDOMSerializer();
                        serial.serialize(raw_records[i].getDocument()
                                                       .getDocumentElement());
                    } catch (Exception e) {
                        LOGGER.severe("Problem serializing dom tree to"
                            + " result record" + e.getMessage());
                    }

                    rec.direct_reference = reg.oidByName(requested_syntax_name);
                    rec.encoding = new encoding_inline0_type();
                    rec.encoding.which = encoding_inline0_type.octet_aligned_CID;
                    rec.encoding.o = sw.toString().getBytes();
                } else { //if  ( requested_syntax_name.equals

                    //    (Z3950Constants.RECSYN_SUTRS)){
                    rec.direct_reference = reg.oidByName(requested_syntax_name);
                    rec.encoding = new encoding_inline0_type();
                    rec.encoding.which = encoding_inline0_type.single_asn1_type_CID;
                    rec.encoding.o = ((String) (raw_records[i]
                        .getOriginalObject()));
                }

                v.add(npr);
            }
        } catch (PresentException pe) {
            LOGGER.warning("Processing present exception: " + pe.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");

            if (pe.additional != null) {
View Full Code Here


    //(use DiagFormat_type from jzkit) and specify exactly what the problem is
    private Records_type createNSD(String diag_code, String additional) {
        Records_type retval = new Records_type();
        retval.which = Records_type.nonsurrogatediagnostic_CID;

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

        default_diag.diagnosticSetId = reg.oidByName("diag-1");

        if (diag_code != null) {
View Full Code Here

     * @param e DOCUMENT ME!
     */
    public void incomingDeleteResultSetRequest(APDUEvent e) {
        LOGGER.finer("Incoming deleteResultSetRequest");

        DeleteResultSetRequest_type delete_request = (DeleteResultSetRequest_type) (e
            .getPDU().o);

        // Create a DeleteResultSetResponse
        PDU_type pdu = new PDU_type();
        pdu.which = PDU_type.deleteresultsetresponse_CID;
View Full Code Here

        // Create a DeleteResultSetResponse
        PDU_type pdu = new PDU_type();
        pdu.which = PDU_type.deleteresultsetresponse_CID;

        DeleteResultSetResponse_type response = new DeleteResultSetResponse_type();
        pdu.o = response;
        response.referenceId = delete_request.referenceId;

        if (delete_request.deleteFunction.intValue() == 0) {
            // Delete the result sets identified by
View Full Code Here

         * out what's in a class, you need to first use which, and then
         * access the object stored based on the which value.  Yeah, it's
         * pretty obscure, and jzkit documentation is not that good.  But
         * read through the code and it might make a little more sense.  I'll
         * try to point out a few examples. */
        InitializeRequest_type init_request = (InitializeRequest_type) (e
            .getPDU().o);

        /* Like here, we have to cast the object held in the PDU to the
         * InitializeRequest_type class, so we can use it.*/
        for (int i = 0; i < Z3950Constants.z3950_option_names.length; i++) {
View Full Code Here

            }

            for (int i = 0; i < raw_records.length; i++) {
                LOGGER.finer("Adding record " + i + " to result");

                NamePlusRecord_type npr = new NamePlusRecord_type();
                npr.name = raw_records[i].getSourceCollectionName();
                npr.record = new record_inline13_type();
                npr.record.which = record_inline13_type.retrievalrecord_CID;

                EXTERNAL_type rec = new EXTERNAL_type();
View Full Code Here

            for (Enumeration other_info_enum = init_request.otherInfo.elements();
                    other_info_enum.hasMoreElements();) {
                LOGGER.finer("Processing otherInfo entry...");

                // Process the external at other_info_enum.nextElement();
                OtherInformationItem43_type oit = (OtherInformationItem43_type) (other_info_enum
                    .nextElement());

                LOGGER.finer("Processing OtherInformationItem43_type");

                switch (oit.information.which) {
View Full Code Here

        LOGGER.finer("Processing incomingSearch_Request");

        SearchRequest_type search_request = (SearchRequest_type) (e.getPDU().o);

        // Create a search response
        PDU_type pdu = new PDU_type();
        pdu.which = PDU_type.searchresponse_CID;

        SearchResponse_type response = new SearchResponse_type();
        pdu.o = response;
View Full Code Here

            //default to full record.
            requested_element_set = GeoProfile.FULL_SET;
        }

        // Create a present response
        PDU_type pdu = new PDU_type();
        pdu.which = PDU_type.presentresponse_CID;

        PresentResponse_type response = new PresentResponse_type();
        pdu.o = response;
        response.referenceId = present_request.referenceId;
View Full Code Here

        DeleteResultSetRequest_type delete_request = (DeleteResultSetRequest_type) (e
            .getPDU().o);

        // Create a DeleteResultSetResponse
        PDU_type pdu = new PDU_type();
        pdu.which = PDU_type.deleteresultsetresponse_CID;

        DeleteResultSetResponse_type response = new DeleteResultSetResponse_type();
        pdu.o = response;
        response.referenceId = delete_request.referenceId;
View Full Code Here

TOP

Related Classes of com.k_int.gen.Z39_50_APDU_1995.PDU_type

Copyright © 2018 www.massapicom. 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.