Exemple #1
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 #2
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();
    }
  }