Package gov.loc.www.zing.srw

Examples of gov.loc.www.zing.srw.ScanResponseType


           
            SRWPort port=service.getSRW(url);
            ScanRequestType scanRequest=new ScanRequestType();
            scanRequest.setVersion("1.1");
            scanRequest.setScanClause("education");
            ScanResponseType scanResponse=port.scanOperation(scanRequest);
            if(scanResponse!=null) {
                TermsType terms=scanResponse.getTerms();
                if(terms!=null) {
                    TermType[] term=terms.getTerm();
                    System.out.println(term.length+" terms returned");
                    for(int i=0; i<term.length; i++)
                        System.out.println(term[i].getValue()+"("+term[i].getNumberOfRecords().intValue()+")");
View Full Code Here


           
            SRWPort port=service.getSRW(url);
            ScanRequestType scanRequest=new ScanRequestType();
            scanRequest.setVersion("1.1");
            scanRequest.setScanClause("education");
            ScanResponseType scanResponse=port.scanOperation(scanRequest);
            if(scanResponse!=null) {
                TermsType terms=scanResponse.getTerms();
                if(terms!=null) {
                    TermType[] term=terms.getTerm();
                    System.out.println(term.length+" terms returned");
                    for(int i=0; i<term.length; i++)
                        System.out.println(term[i].getValue()+"("+term[i].getNumberOfRecords().intValue()+")");
View Full Code Here

                    scanRequest.setVersion("1.1");
                    System.out.println("&scanClause="+scanClause);
                    scanRequest.setScanClause(scanClause);
                    scanRequest.setMaximumTerms(new PositiveInteger(Integer.toString(maximumTerms)));
                    scanRequest.setResponsePosition(new NonNegativeInteger(Integer.toString(responsePosition)));
                    ScanResponseType scanResponse = db.doRequest(scanRequest);
                    if(scanResponse != null) {
                        TermsType terms = scanResponse.getTerms();
                        if(terms != null) {
                            TermType term[] = terms.getTerm();
                            System.out.println(term.length + " terms returned");
                            for(i = 0; i < term.length; i++)
                                System.out.println(term[i].getValue() + "(" + term[i].getNumberOfRecords().intValue() + ")");
View Full Code Here

    public ScanResponseType scanOperation(ScanRequestType request)
      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
                if(db.databaseTitle!=null)
                    extraResponseData.append("<databaseTitle>").append(db.databaseTitle).append("</databaseTitle>");
                else
                    extraResponseData.append("<databaseTitle>").append(dbname).append("</databaseTitle>");

//                Hashtable extraRequestDataElements=SRWDatabase.parseElements(request.getExtraRequestData());
//                String s=(String)extraRequestDataElements.get("returnTargetURL");
//                log.info("returnTargetURL="+s);
//                if(s!=null && !s.equals("false")) {
//                    String targetStr=(String)msgContext.getProperty("targetURL");
//                    log.info("targetStr="+targetStr);
//                    if(targetStr!=null && targetStr.length()>0) {
//                        URL target=new URL(targetStr);
//                        extraResponseData.append("<targetURL>")
//                            .append("<host>").append(target.getHost()).append("</host>")
//                            .append("<port>").append(target.getPort()).append("</port>")
//                            .append("<path>").append(target.getPath()).append("</path>")
//                            .append("<query>").append(Utilities.xmlEncode(target.getQuery())).append("</query>")
//                            .append("</targetURL>");
//                    }
//                }

                // set extraResponseData
                SRWDatabase.setExtraResponseData(response, extraResponseData.toString());
            }
            catch(Exception e) {
                log.error(e, e);
                throw new RemoteException(e.getMessage(), e);
            }
            finally {
                SRWDatabase.putDb(dbname, db);
            }
        if(response!=null) {
                log.info("calling setEchoedScanRequestType");
            setEchoedScanRequestType(request, response);
                log.info("called setEchoedScanRequestType");
            response.setVersion("1.1");
        }
        log.debug("Exit: scanOperation");
        return response;
    }
View Full Code Here


    public ScanResponseType doRequest(ScanRequestType request) throws ServletException {
        searchRequest=null;
        response=null;
        ScanResponseType scanResponse = new ScanResponseType();
        String version=request.getVersion();
        if(version!=null && !version.equals("1.1"))
            return diagnostic(SRWDiagnostic.UnsupportedVersion, version, scanResponse);

        CQLTermNode root = null;
        int max = maxTerms,  pos = position;
        long startTime = System.currentTimeMillis();
        PositiveInteger pi = request.getMaximumTerms();
        if(pi!=null) {
            max=pi.intValue();
            pos=max/2+1;
        }
        NonNegativeInteger nni = request.getResponsePosition();
        if(nni!=null)
            pos=nni.intValue();
        String scanTerm = request.getScanClause();
        try{
            if (scanTerm!=null)
                log.info("scanTerm:\n" + Utilities.byteArrayToString(scanTerm.getBytes("UTF-8")));
        } catch (Exception e){}
        log.info("maxTerms="+max+", position="+pos);
        try {
            root = Utilities.getFirstTerm(parser.parse(scanTerm));
        } catch (CQLParseException e) {
            log.error(e);
            return diagnostic(SRWDiagnostic.QuerySyntaxError, e.getMessage(),
                scanResponse);
        } catch (IOException e) {
            log.error(e);
            return diagnostic(SRWDiagnostic.QuerySyntaxError, e.getMessage(),
                scanResponse);
        }
        if (root.getTerm().length()==0)
            // The method getQualifier() was replaced by getIndex() in version
            // 1.0 of the parser. This code ensures that either one works.
            //root = new CQLTermNode(root.getQualifier(), root.getRelation(), "$");
            root = new CQLTermNode(SRWSoapBindingImpl.getQualifier(root), root.getRelation(), "$");
        String resultSetID = root.getResultSetName();
        if (resultSetID!=null) { // you can't scan on resultSetId!
            return diagnostic(SRWDiagnostic.UnsupportedIndex,
                    "cql.resultSetId", scanResponse);
        }
        TermsType terms = new TermsType();
        TermList tl=getTermList(root, pos, max, request);
        terms.setTerm(tl.getTerms());
        scanResponse.setTerms(terms);

        Vector<DiagnosticType> diagnostics = tl.getDiagnostics();
        if (diagnostics!=null && !diagnostics.isEmpty()) {
            DiagnosticType diagArray[] = new DiagnosticType[diagnostics.size()];
            diagnostics.toArray(diagArray);
            scanResponse.setDiagnostics(new DiagnosticsType(diagArray));
        }

        log.info("scan "+scanTerm+": (" + (System.currentTimeMillis() - startTime) + "ms)");
        return scanResponse;
    }
View Full Code Here

        }
        catch(IllegalArgumentException e) {
        }

        try {
            Utilities.objToSru(new ScanResponseType());
            fail("should have thrown an IllegalArgumentException");
        }
        catch(IllegalArgumentException e) {
        }
View Full Code Here

       
        SearchRetrieveResponseType srresp=new SearchRetrieveResponseType();
        srresp.setVersion("1.1");
        Utilities.objToXml(srresp);

        ScanResponseType sresp=new ScanResponseType();
        sresp.setVersion("1.1");
        Utilities.objToXml(sresp);

        try {
            Utilities.objToXml(this);
            fail("should have thrown an IllegalArgumentException");
View Full Code Here

           
            SRWPort port=service.getSRW(url);
            ScanRequestType scanRequest=new ScanRequestType();
            scanRequest.setVersion("1.1");
            scanRequest.setScanClause("education");
            ScanResponseType scanResponse=port.scanOperation(scanRequest);
            if(scanResponse!=null) {
                TermsType terms=scanResponse.getTerms();
                if(terms!=null) {
                    TermType[] term=terms.getTerm();
                    System.out.println(term.length+" terms returned");
                    for(int i=0; i<term.length; i++)
                        System.out.println(term[i].getValue()+"("+term[i].getNumberOfRecords().intValue()+")");
View Full Code Here

TOP

Related Classes of gov.loc.www.zing.srw.ScanResponseType

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.