Exemplo n.º 1
0
 private static CQLQueryResults queryStandard(
     CQLQuery query, String targetServiceURL, GlobusCredential cred)
     throws RemoteDataServiceException {
   LOG.debug("Querying " + targetServiceURL + " with standard CQL 2 query mechanism");
   DataServiceClient client = null;
   try {
     client = new DataServiceClient(targetServiceURL, cred);
   } catch (MalformedURIException ex) {
     throw new RemoteDataServiceException("Invalid target service URL:" + targetServiceURL, ex);
   } catch (RemoteException ex) {
     String message = "Problem creating client for " + targetServiceURL + ": " + ex.getMessage();
     LOG.error(message, ex);
     throw new RemoteDataServiceException(message, ex);
   }
   // if we have been supplied a credential, make sure we always use it
   if (cred != null) {
     client.setAnonymousPrefered(false);
   }
   CQLQueryResults results = null;
   try {
     results = client.executeQuery(query);
   } catch (RemoteException e) {
     String message =
         "Problem querying remote service " + targetServiceURL + ": " + e.getMessage();
     LOG.error(message, e);
     throw new RemoteDataServiceException(message, e);
   }
   return results;
 }
Exemplo n.º 2
0
 private static CQLQueryResults queryStandardCql1(
     CQLQuery query, String targetServiceURL, GlobusCredential cred)
     throws RemoteDataServiceException {
   LOG.debug("Querying " + targetServiceURL + " with deprecated CQL 1 query mechanism");
   DataServiceClient client = null;
   try {
     client = new DataServiceClient(targetServiceURL, cred);
   } catch (MalformedURIException ex) {
     throw new RemoteDataServiceException("Invalid target service URL:" + targetServiceURL, ex);
   } catch (RemoteException ex) {
     String message = "Problem creating client for " + targetServiceURL + ": " + ex.getMessage();
     LOG.error(message, ex);
     throw new RemoteDataServiceException(message, ex);
   }
   // if we have been supplied a credential, make sure we always use it
   if (cred != null) {
     client.setAnonymousPrefered(false);
   }
   LOG.debug("Converting CQL 2 to CQL 1 for " + targetServiceURL);
   gov.nih.nci.cagrid.cqlquery.CQLQuery cql1Query = null;
   try {
     cql1Query = CQL2toCQL1Converter.convertToCql1Query(query);
   } catch (QueryConversionException ex) {
     throw new RemoteDataServiceException(
         "Error converting query to CQL 1 for " + targetServiceURL + ": " + ex.getMessage(), ex);
   }
   CQLQueryResults results = null;
   try {
     if (LOG.isDebugEnabled()) {
       try {
         StringWriter s = new StringWriter();
         SerializationUtils.serializeCQLQuery(cql1Query, s);
         LOG.debug(
             "Sending converted CQL 1 query to service ("
                 + targetServiceURL
                 + "):\n"
                 + s.toString());
         s.close();
       } catch (Exception e) {
         LOG.error("Problem in debug printout of CQL query: " + e.getMessage(), e);
       }
     }
     gov.nih.nci.cagrid.cqlresultset.CQLQueryResults cql1Results = client.query(cql1Query);
     results = CQL1ResultsToCQL2ResultsConverter.convertResults(cql1Results);
   } catch (RemoteException e) {
     String message =
         "Problem querying remote service " + targetServiceURL + ": " + e.getMessage();
     LOG.error(message, e);
     throw new RemoteDataServiceException(message, e);
   } catch (ResultsConversionException e) {
     String message =
         "Problem converting results from remote service "
             + targetServiceURL
             + ": "
             + e.getMessage();
     LOG.error(message, e);
     throw new RemoteDataServiceException(message, e);
   }
   return results;
 }