Ejemplo n.º 1
0
 public gov.nih.nci.cagrid.dcqlresult.DCQLQueryResultsCollection execute(
     gov.nih.nci.cagrid.dcql.DCQLQuery query)
     throws RemoteException, gov.nih.nci.cagrid.fqp.stubs.types.FederatedQueryProcessingFault {
   FederatedQueryEngine engine = new FederatedQueryEngine();
   DCQLQueryResultsCollection results = null;
   try {
     results = engine.execute(query);
   } catch (FederatedQueryProcessingException e) {
     LOG.error("Problem executing query: " + e.getMessage());
     FederatedQueryProcessingFault fault = new FederatedQueryProcessingFault();
     fault.setFaultString("Problem executing query: " + e.getMessage());
     FaultHelper helper = new FaultHelper(fault);
     helper.addFaultCause(e);
     throw helper.getFault();
   }
   return results;
 }
Ejemplo n.º 2
0
 private gov.nih.nci.cagrid.fqp.results.stubs.types.FederatedQueryResultsReference createEPR(
     ResourceKey key) throws RemoteException {
   MessageContext ctx = MessageContext.getCurrentContext();
   String transportURL = (String) ctx.getProperty(org.apache.axis.MessageContext.TRANS_URL);
   transportURL = transportURL.substring(0, transportURL.lastIndexOf('/') + 1);
   // TODO: fix this somehow (pull from property or constant)
   transportURL += "FederatedQueryResults";
   try {
     EndpointReferenceType epr = AddressingUtils.createEndpointReference(transportURL, key);
     return new FederatedQueryResultsReference(epr);
   } catch (Exception e) {
     LOG.error("Problem returning reference to result:" + e.getMessage(), e);
     InternalErrorFault fault = new InternalErrorFault();
     fault.setFaultString("Problem returning reference to result:" + e.getMessage());
     FaultHelper helper = new FaultHelper(fault);
     helper.addFaultCause(e);
     throw helper.getFault();
   }
 }
Ejemplo n.º 3
0
  public gov.nih.nci.cagrid.fqp.results.stubs.types.FederatedQueryResultsReference
      executeAsynchronously(gov.nih.nci.cagrid.dcql.DCQLQuery query) throws RemoteException {

    // create a result resource
    FQPResultResourceHome resultHome = null;
    try {
      resultHome = (FQPResultResourceHome) getFederatedQueryResultsResourceHome();
    } catch (Exception e) {
      LOG.error("Problem locating result home: " + e.getMessage(), e);
      InternalErrorFault fault = new InternalErrorFault();
      fault.setFaultString("Problem locating result home:" + e.getMessage());
      FaultHelper helper = new FaultHelper(fault);
      helper.addFaultCause(e);
      throw helper.getFault();
    }

    FQPResultResource fqpResultResource = null;
    ResourceKey key = null;
    try {
      key = resultHome.createFQPResultResource();
      fqpResultResource = (FQPResultResource) resultHome.find(key);
    } catch (Exception e) {
      LOG.error("Problem creating and accessing resource:" + e.getMessage(), e);
      InternalErrorFault fault = new InternalErrorFault();
      fault.setFaultString("Problem creating and accessing resource:" + e.getMessage());
      FaultHelper helper = new FaultHelper(fault);
      helper.addFaultCause(e);
      throw helper.getFault();
    }

    // configure security on the resource so only the creator of the
    // resource (whoever is executing this) can operate on it
    try {
      // may be null if no current caller
      fqpResultResource.setSecurityDescriptor(
          SecurityUtils.createResultsResourceSecurityDescriptor());
    } catch (Exception e) {
      LOG.error("Problem configuring security on resource:" + e.getMessage(), e);
      InternalErrorFault fault = new InternalErrorFault();
      fault.setFaultString("Problem configuring security on resource:" + e.getMessage());
      FaultHelper helper = new FaultHelper(fault);
      helper.addFaultCause(e);
      throw helper.getFault();
    }

    LOG.info("Resource created for, and owned by: " + SecurityManager.getManager().getCaller());

    // set initial status
    fqpResultResource.setStatusMessage("Queued for processing");
    // set to terminate after lease expires
    Calendar termTime = Calendar.getInstance();
    termTime.add(Calendar.MINUTE, getLeaseDurationInMinutes());
    fqpResultResource.setTerminationTime(termTime);

    // create a worker thread to execute query
    Work work = new QueryExecutionWork(fqpResultResource, query);

    // add worker to pool
    try {
      getWorkManager().schedule(work);
    } catch (Exception e) {
      LOG.error("Problem scheduling processing:" + e.getMessage(), e);
      InternalErrorFault fault = new InternalErrorFault();
      fault.setFaultString("Problem scheduling processing:" + e.getMessage());
      FaultHelper helper = new FaultHelper(fault);
      helper.addFaultCause(e);
      throw helper.getFault();
    }

    // return handle to resource
    return createEPR(key);
  }