Exemple #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();
    }
  }
Exemple #2
0
  public ServiceDetail getServiceDetail(GetServiceDetail body)
      throws DispositionReportFaultMessage {
    long startTime = System.nanoTime();
    try {
      new ValidateInquiry(null).validateGetServiceDetail(body);
    } catch (DispositionReportFaultMessage drfm) {
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.GET_SERVICEDETAIL, QueryStatus.FAILED, procTime);
      throw drfm;
    }

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

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

      ServiceDetail result = new ServiceDetail();

      List<String> serviceKeyList = body.getServiceKey();
      for (String serviceKey : serviceKeyList) {
        org.apache.juddi.model.BusinessService modelBusinessService = null;
        try {
          modelBusinessService = em.find(org.apache.juddi.model.BusinessService.class, serviceKey);
        } catch (ClassCastException e) {
        }
        if (modelBusinessService == null)
          throw new InvalidKeyPassedException(
              new ErrorMessage("errors.invalidkey.ServiceNotFound", serviceKey));

        org.uddi.api_v3.BusinessService apiBusinessService = new org.uddi.api_v3.BusinessService();

        MappingModelToApi.mapBusinessService(modelBusinessService, apiBusinessService);

        result.getBusinessService().add(apiBusinessService);
      }

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

      return result;

    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      em.close();
    }
  }
Exemple #3
0
  public OperationalInfos getOperationalInfo(GetOperationalInfo body)
      throws DispositionReportFaultMessage {
    long startTime = System.nanoTime();
    try {
      new ValidateInquiry(null).validateGetOperationalInfo(body);
    } catch (DispositionReportFaultMessage drfm) {
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.GET_OPERATIONALINFO, QueryStatus.FAILED, procTime);
      throw drfm;
    }

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

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

      OperationalInfos result = new OperationalInfos();

      List<String> entityKeyList = body.getEntityKey();
      for (String entityKey : entityKeyList) {
        org.apache.juddi.model.UddiEntity modelUddiEntity = null;
        try {
          modelUddiEntity = em.find(org.apache.juddi.model.UddiEntity.class, entityKey);
        } catch (ClassCastException e) {
        }
        if (modelUddiEntity == null)
          throw new InvalidKeyPassedException(
              new ErrorMessage("errors.invalidkey.EntityNotFound", entityKey));

        org.uddi.api_v3.OperationalInfo apiOperationalInfo = new org.uddi.api_v3.OperationalInfo();

        MappingModelToApi.mapOperationalInfo(modelUddiEntity, apiOperationalInfo);

        result.getOperationalInfo().add(apiOperationalInfo);
      }

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

      return result;
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      em.close();
    }
  }
Exemple #4
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();
    }
  }
Exemple #5
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();
    }
  }