Exemplo n.º 1
0
  public ServiceList findService(FindService body) throws DispositionReportFaultMessage {
    long startTime = System.nanoTime();
    try {
      new ValidateInquiry(null).validateFindService(body);
    } catch (DispositionReportFaultMessage drfm) {
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.FIND_SERVICE, QueryStatus.FAILED, procTime);
      throw drfm;
    }

    EntityManager em = PersistenceManager.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    try {
      tx.begin();

      if (isAuthenticated()) this.getEntityPublisher(em, body.getAuthInfo());

      org.apache.juddi.query.util.FindQualifiers findQualifiers =
          new org.apache.juddi.query.util.FindQualifiers();
      findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());

      List<?> keysFound = InquiryHelper.findService(body, findQualifiers, em);

      if (keysFound.size() == 0) {
        if (body.getBusinessKey() != null) {
          // Check that we were passed a valid businessKey per
          // 5.1.12.4 of the UDDI v3 spec
          String businessKey = body.getBusinessKey();
          org.apache.juddi.model.BusinessEntity modelBusinessEntity = null;
          try {
            modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class, businessKey);
          } catch (ClassCastException e) {
          }
          if (modelBusinessEntity == null) {
            throw new InvalidKeyPassedException(
                new ErrorMessage("errors.invalidkey.BusinessNotFound", businessKey));
          }
        }
      }

      ServiceList result =
          InquiryHelper.getServiceListFromKeys(body, findQualifiers, em, keysFound);

      tx.rollback();
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.FIND_SERVICE, QueryStatus.SUCCESS, procTime);

      return result;
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      em.close();
    }
  }
Exemplo n.º 2
0
  public RelatedBusinessesList findRelatedBusinesses(FindRelatedBusinesses body)
      throws DispositionReportFaultMessage {
    long startTime = System.nanoTime();
    try {
      new ValidateInquiry(null).validateFindRelatedBusinesses(body, false);
    } catch (DispositionReportFaultMessage drfm) {
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.FIND_RELATEDBUSINESSES, QueryStatus.FAILED, procTime);
      throw drfm;
    }

    EntityManager em = PersistenceManager.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    try {
      tx.begin();

      if (isAuthenticated()) this.getEntityPublisher(em, body.getAuthInfo());

      // TODO: findQualifiers aren't really used for this call, except maybe for sorting.  Sorting
      // must be done in Java due to the retrieval method used.  Right now
      // no sorting is performed.
      org.apache.juddi.query.util.FindQualifiers findQualifiers =
          new org.apache.juddi.query.util.FindQualifiers();
      findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());

      RelatedBusinessesList result = InquiryHelper.getRelatedBusinessesList(body, em);

      tx.rollback();
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.FIND_RELATEDBUSINESSES, QueryStatus.SUCCESS, procTime);

      return result;
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      em.close();
    }
  }
Exemplo n.º 3
0
  public BusinessList findBusiness(FindBusiness body) throws DispositionReportFaultMessage {
    long startTime = System.nanoTime();
    try {
      new ValidateInquiry(null).validateFindBusiness(body);
    } catch (DispositionReportFaultMessage drfm) {
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.FIND_BUSINESS, QueryStatus.FAILED, procTime);
      throw drfm;
    }

    EntityManager em = PersistenceManager.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    try {
      tx.begin();

      if (isAuthenticated()) this.getEntityPublisher(em, body.getAuthInfo());

      org.apache.juddi.query.util.FindQualifiers findQualifiers =
          new org.apache.juddi.query.util.FindQualifiers();
      findQualifiers.mapApiFindQualifiers(body.getFindQualifiers());

      List<?> keysFound = InquiryHelper.findBusiness(body, findQualifiers, em);

      BusinessList result =
          InquiryHelper.getBusinessListFromKeys(body, findQualifiers, em, keysFound);

      tx.rollback();
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.FIND_BUSINESS, QueryStatus.SUCCESS, procTime);

      return result;
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      em.close();
    }
  }