Question

I have a webservice which searches for pieces of texts in modeshape content repository. The interface looks something like this :

 @POST
    @Path("globalSearch")
    @Consumes(MediaType.TEXT_PLAIN)
    @Produces(MediaType.TEXT_XML)
    public String globalSearch(String search) {
        XMLConverterService xmlOb = new XMLConverterService();
        Map<String,String> param = xmlOb.fetchMapFromXml(search);
        StringBuffer xmlString = new StringBuffer();
        xmlString.append("<xml>");
        int count = 0;
        List<Map<String, String>> result = (new DataInterfaceService())
                .fetchGlobalSearch(param);
        if(result!=null){
        for (Map<String, String> map : result) {
            count++;
            xmlString.append("<result" + count + ">")
                    .append(xmlOb.fetchXmlFromMap(map))
                    .append("</result" + count + ">");
        }
        xmlString.append("</xml>");
        return xmlString.toString();
        }
        return null;
    }

the fetchGlobalSearch() function looks something like this :

public List<Map<String, String>> fetchGlobalSearch(Map<String, String> param) {
    logger.log(Level.INFO, "entering fetchGlobalSearch");
    String keyWord = param.get("keyword");
    String type = param.get("type");
    List<Map<String, String>> listOfMaps = null;
    Map<String, String> retValue = null;
    String qry = "";
    if (type.equalsIgnoreCase("GRA")) {
        qry = "SELECT [med:UNIQUE_ID],[med:GRPNAME],[med:CSR],[med:UW],[med:GROUP_STATE],[med:STR_DATE] "
                + "FROM [med:notes] where contains([med:XML_STORE], $uuid)";
    } else {
        qry = "SELECT [fur:UNIQUE_ID],[fur:MM],[fur:FROMUW],[fur:INSURED],[fur:POLICY_NUM],[fur:UWCSRDATE],[fur:FURCOMPDATE],[fur:FUR_DATE],[fur:CSRCOMPDATE] "
                + "FROM [fur:notesfur] where contains([fur:XML_STORE], $uuid)";
    }
    try {
        Query qr = qrym.createQuery(qry, Query.JCR_SQL2);

        Value uid = session.getValueFactory().createValue(keyWord);
        qr.bindValue("uuid", uid);

        QueryResult resultSet = qr.execute();
        String[] columns = resultSet.getColumnNames();

        RowIterator rowiter = resultSet.getRows();

        while (rowiter.hasNext()) {
            if (listOfMaps == null)
                listOfMaps = new ArrayList<Map<String, String>>();
            retValue = new HashMap<String, String>();
            Row row = rowiter.nextRow();
            for (String column : columns) {
                if (row.getValue(column) != null) {
                    retValue.put(column, row.getValue(column).toString());
                }
            }
            listOfMaps.add(retValue);
        }

    } catch (RepositoryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    logger.log(Level.INFO, "exiting fetchGlobalSearch");
    return listOfMaps;
}

I access the webservice by following piece of code :

private static void callGlobalSearch(){
        try {
            String param = "";
            param = fetchGlobalParams();
            System.out.println("param : " + param);
            // Create a socket connection to the host
            URL url = new URL(
                    "http://localhost:8080/xxttrr/rest/globalSearch");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            // make url connection
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setAllowUserInteraction(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type",
                    "text/plain; charset=utf-8");
            conn.setRequestProperty("Content-Length", Integer.toString(param.getBytes().length));
            DataOutputStream printout = new DataOutputStream (conn.getOutputStream());
            printout.writeBytes(param);
            printout.flush();
            printout.close();
            BufferedReader in = new BufferedReader(new java.io.InputStreamReader(conn.getInputStream()));
            String line;            
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            conn.disconnect();
        } catch (Exception e) {
            System.out.println("Error: " + e);
        }

    }

The problem is when I make a webservice call to my local modeshape repository, the result is returned as expected. but when I deploy the code in my DEV server it forms following log :

14:32:47,033 INFO [DataInterfaceService] (http-/0.0.0.0:8380-1) entering fetchGlobalSearch
14:32:47,035 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule org.modeshape.jcr.query.optimize.RewritePseudoColumns@580ba9a4
14:32:47,036 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule ReplaceViews
14:32:47,036 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule CopyCriteria
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule RightOuterToLeftOuterJoins
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule AddAccessNodes
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule PushSelectCriteria
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule PushProjects
14:32:47,037 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule AddOrderingColumnsToSources
14:32:47,038 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule RewriteAsRangeCriteria
14:32:47,038 DEBUG [org.modeshape.jcr.query.optimize.RuleBasedOptimizer] (http-/0.0.0.0:8380-1) Running query optimizer rule RewritePathAndNameCriteria
14:32:47,039 DEBUG [org.modeshape.jcr.query.lucene.LuceneQueryEngine] (http-/0.0.0.0:8380-1) Executing the lucene query: +(::wks:System ::wks:Default) +:ft:ddd:XML_STORE:"uuid" +jcr:mixinTypes:ddd:notes
14:32:47,051 INFO [DataInterfaceService] (http-/0.0.0.0:8380-1) exiting fetchGlobalSearch

and terminates.

Is it something to do with modeshape configuration or webservice? Just to let you know, at a point there might be a million records in modeshape. so is the timeout causing an issue. if so, then how can I configure my webservice so that it can live for say 5 mins?

Any help would be appreciated. It's really confusing as to how the same code behaves differently in different servers.

Était-ce utile?

La solution

It was nothing. the error said it all. Apparently uuid should not be used as a variable name for passing parameters to SQL2 queries. changed it to uid and it worked like a charm.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top