Package ORG.oclc.os.SRW

Examples of ORG.oclc.os.SRW.SRWDatabase


            log.debug("ttl="+ttl);
            if(ttl<resultSetIdleTime)
                resultSetIdleTime=ttl;
        }
        String dbname=(String)msgContext.getProperty("dbname");
        SRWDatabase db=(SRWDatabase)msgContext.getProperty("db");
        if(log.isDebugEnabled())
            log.debug("db="+db);

        String sortKeys=request.getSortKeys();
        if(sortKeys!=null)
            request.setSortKeys(sortKeys);

        String query=request.getQuery();
        if(query.indexOf('%')>=0)
            try {
                request.setQuery(java.net.URLDecoder.decode(query, "utf-8"));
            }
            catch (java.io.UnsupportedEncodingException e) {
            }
        if(query==null) {
            response=new SearchRetrieveResponseType();
            db.diagnostic(SRWDiagnostic.MandatoryParameterNotSupplied,
                "query", response);
        }
        else if(request.getStartRecord()!=null &&
          request.getStartRecord().intValue()==Integer.MAX_VALUE) {
            response=new SearchRetrieveResponseType();
            db.diagnostic(SRWDiagnostic.UnsupportedParameterValue,
                "startRecord", response);
        }
        else if(request.getMaximumRecords()!=null &&
          request.getMaximumRecords().intValue()==Integer.MAX_VALUE) {
            response=new SearchRetrieveResponseType();
            db.diagnostic(SRWDiagnostic.UnsupportedParameterValue,
                "maximumRecords", response);
        }
        else if(request.getResultSetTTL()!=null &&
          request.getResultSetTTL().intValue()==Integer.MAX_VALUE) {
            response=new SearchRetrieveResponseType();
            db.diagnostic(SRWDiagnostic.UnsupportedParameterValue,
                "resultSetTTL", response);
        }
        else
        try {
            response=db.doRequest(request);
            if(response==null) {
                response=new SearchRetrieveResponseType();
                response.setVersion("1.1");
                setEchoedSearchRetrieveRequestType(request, response);
                db.diagnostic(SRWDiagnostic.GeneralSystemError, null, response);
                return response;
            }
            if(msgContext.getProperty("sru")!=null &&
              request.getStylesheet()!=null) // you can't ask for a stylesheet in srw!
                db.diagnostic(SRWDiagnostic.StylesheetsNotSupported, null, response);

            setEchoedSearchRetrieveRequestType(request, response);
            if(request.getRecordXPath()!=null)
                db.diagnostic(72, null, response);
            if(request.getSortKeys()!=null &&
              !request.getSortKeys().equals("") && !db.supportsSort())
                db.diagnostic(SRWDiagnostic.SortNotSupported, null, response);

            // set extraResponseData
            StringBuffer extraResponseData = new StringBuffer();

            // we're going to stick the database name in extraResponseData every time
View Full Code Here


      throws java.rmi.RemoteException {
        log.debug("Enter: scanOperation");
        MessageContext   msgContext=MessageContext.getCurrentContext();
        ScanResponseType response;
        String dbname=(String)msgContext.getProperty("dbname");
        SRWDatabase db=(SRWDatabase)msgContext.getProperty("db");
        if(log.isDebugEnabled())
            log.debug("db="+db);
        if(request.getScanClause()==null) {
            response=new ScanResponseType();
            db.diagnostic(SRWDiagnostic.MandatoryParameterNotSupplied,
                "scanClause", response);
        }
        else if(request.getResponsePosition()!=null &&
          request.getResponsePosition().intValue()==Integer.MAX_VALUE) {
            response=new ScanResponseType();
            db.diagnostic(SRWDiagnostic.UnsupportedParameterValue,
                "responsePosition", response);
        }
        else if(request.getMaximumTerms()!=null &&
          request.getMaximumTerms().intValue()==Integer.MAX_VALUE) {
            response=new ScanResponseType();
            db.diagnostic(SRWDiagnostic.UnsupportedParameterValue,
                "maximumTerms", response);
        }
        else
            try {
                response=db.doRequest(request);

                // set extraResponseData
                StringBuffer extraResponseData = new StringBuffer();

                // we're going to stick the database name in extraResponseData every time
View Full Code Here

    public ExplainResponseType explainOperation(ExplainRequestType request)
      throws java.rmi.RemoteException {
        MessageContext   msgContext=MessageContext.getCurrentContext();
        ExplainResponseType response=new ExplainResponseType();
        String dbname=(String)msgContext.getProperty("dbname");
        SRWDatabase db=(SRWDatabase)msgContext.getProperty("db");
        log.info("db="+db);
        response.setVersion("1.1");
        RecordType record=new RecordType();
        record.setRecordSchema("http://explain.z3950.org/dtd/2.0/");
        StringOrXmlFragment frag=new StringOrXmlFragment();
        String recordPacking=request.getRecordPacking();
        if(recordPacking==null) {
            if(msgContext.getProperty("sru")!=null)
                recordPacking="xml"; // default for sru
            else
                recordPacking="string"; // default for srw
        }
        if(!recordPacking.equals("xml") &&
          !recordPacking.equals("string")) {
            return db.diagnostic(71, recordPacking, response);
        }
        try {
            if(recordPacking.equals("xml")) {
                record.setRecordPacking("xml");
                Document domDoc=XMLUtils.newDocument(
                    new InputSource(
                    new StringReader(db.getExplainRecord(null))));
                MessageElement elems[]=new MessageElement[1];
                elems[0]=new MessageElement(
                    domDoc.getDocumentElement());
                frag.set_any(elems);
            }
            else { // srw
                record.setRecordPacking("string");
                MessageElement elems[]=new MessageElement[1];
                elems[0]=new MessageElement();
                elems[0].addTextNode(db.getExplainRecord(null));
                frag.set_any(elems);
            }
            record.setRecordData(frag);
            response.setRecord(record);
        }
View Full Code Here

TOP

Related Classes of ORG.oclc.os.SRW.SRWDatabase

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.