示例#1
0
  public BusinessDetail getBusinessDetail(GetBusinessDetail body)
      throws DispositionReportFaultMessage {
    long startTime = System.nanoTime();
    try {
      new ValidateInquiry(null).validateGetBusinessDetail(body);
    } catch (DispositionReportFaultMessage drfm) {
      long procTime = System.nanoTime() - startTime;
      serviceCounter.update(InquiryQuery.GET_BUSINESSDETAIL, QueryStatus.FAILED, procTime);
      throw drfm;
    }

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

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

      BusinessDetail result = new BusinessDetail();

      List<String> businessKeyList = body.getBusinessKey();
      for (String businessKey : businessKeyList) {
        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));

        org.uddi.api_v3.BusinessEntity apiBusinessEntity = new org.uddi.api_v3.BusinessEntity();

        MappingModelToApi.mapBusinessEntity(modelBusinessEntity, apiBusinessEntity);

        result.getBusinessEntity().add(apiBusinessEntity);
      }

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

      return result;
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
      em.close();
    }
  }
  // JUDDI-716
  @Test()
  public void JUDDI_716_SaveBusinessAllOptions() throws CertificateException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    be.setBusinessKey(TckBusiness.JOE_BUSINESS_KEY);

    Name n = new Name();
    n.setValue("JUDDI_716_SaveBusinessAllOptions");
    be.getName().add(n);
    DigSigUtil ds = GetDigSig();
    ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SERIAL, "true");
    ds.put(DigSigUtil.SIGNATURE_OPTION_CERT_INCLUSION_SUBJECTDN, "true");
    be = ds.signUddiEntity(be);
    sb.getBusinessEntity().add(be);
    BusinessDetail saveBusiness = null;
    try {
      saveBusiness = publicationJoe.saveBusiness(sb);
      GetBusinessDetail gsb = new GetBusinessDetail();
      gsb.setAuthInfo(authInfoJoe);
      gsb.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
      BusinessDetail businessDetail = inquiryJoe.getBusinessDetail(gsb);
      PrintUDDI<BusinessEntity> printer = new PrintUDDI<BusinessEntity>();
      if (TckCommon.isDebug())
        System.out.println(printer.print(businessDetail.getBusinessEntity().get(0)));
      AtomicReference<String> msg = new AtomicReference<String>();
      boolean b = ds.verifySignedUddiEntity(businessDetail.getBusinessEntity().get(0), msg);
      Assert.assertTrue(msg.get(), b);
      Assert.assertTrue(msg.get() == null || msg.get().length() == 0);

    } catch (Exception ex) {
      logger.error("unExpected failure: ", ex);
      Assert.fail("unexpected failure");
    } finally {
      DeleteBusinesses(
          saveBusiness.getBusinessEntity().get(0).getBusinessKey(), authInfoJoe, publicationJoe);
    }
  }
示例#3
0
  /**
   * This method loops through the business entities and fills in any pertinent detailed information
   * by calling the UDDI server get_businessDetail function. Note that this information was not
   * available in the find_business. In order to get it we have to do separate call.
   *
   * @param oEntities The businesses to retrieve the detail and the object where the details will be
   *     placed.
   */
  private void retrieveDetailedBusinessInfoFromUDDI(CMBusinessEntities oEntities)
      throws UDDIAccessorException {
    if ((oEntities == null)
        || (oEntities.getBusinessEntity() == null)
        || (oEntities.getBusinessEntity().size() <= 0)) {
      return; // we are done  there is nothing to retrieve.
    }

    BusinessDetail oResult = null;

    try {
      GetBusinessDetail oSearchParams = new GetBusinessDetail();

      // Load up the list of keys to retrieve the details of...
      // --------------------------------------------------------
      for (CMBusinessEntity oEntity : oEntities.getBusinessEntity()) {
        if ((oEntity.getBusinessKey() != null) && (oEntity.getBusinessKey().length() > 0)) {
          oSearchParams.getBusinessKey().add(oEntity.getBusinessKey());
        }
      } // for (CMBusinessEntity oEntity : oEntities.getBusinessEntity())

      UDDIInquiryPortType oPort = getUDDIInquiryWebService();
      oResult = oPort.getBusinessDetail(oSearchParams);
    } catch (Exception e) {
      String sErrorMessage =
          "Failed to call UDDI web service get_businessDetail method.  Error: " + e.getMessage();
      log.error(sErrorMessage, e);
      throw new UDDIAccessorException(sErrorMessage, e);
    }

    // Now let's process the results...
    // ---------------------------------
    if ((oResult != null)
        && (oResult.getBusinessEntity() != null)
        && (oResult.getBusinessEntity().size() > 0)) {
      // Now put the returned information back into our structure.
      // -----------------------------------------------------------
      for (BusinessEntity oUDDIEntity : oResult.getBusinessEntity()) {
        if ((oUDDIEntity.getBusinessKey() != null) && (oUDDIEntity.getBusinessKey().length() > 0)) {
          CMBusinessEntity oEntity =
              findSpecificBusiness(oEntities.getBusinessEntity(), oUDDIEntity.getBusinessKey());

          if (oEntity != null) {
            // Home community ID
            // ------------------
            if ((oUDDIEntity.getIdentifierBag() != null)
                && (oUDDIEntity.getIdentifierBag().getKeyedReference() != null)
                && (oUDDIEntity.getIdentifierBag().getKeyedReference().size() > 0)) {
              List<String> oValues =
                  findAndGetValueFromKeyedReference(
                      oUDDIEntity.getIdentifierBag().getKeyedReference(), HOME_COMMUNITY_ID_KEY);
              if (oValues != null && oValues.size() == 1) {
                for (String sValue : oValues) {
                  if ((sValue != null) && (sValue.length() > 0)) {
                    if (sValue.startsWith("urn:oid:")) {
                      sValue = sValue.substring("urn:oid:".length());
                    }
                    oEntity.setHomeCommunityId(sValue);
                  }
                }
              } else {
                log.debug(
                    "A single Home Community value is NOT detected for UDDI Entity "
                        + oUDDIEntity.getBusinessKey());
              }
            } // if ((oUDDIEntity.getIdentifierBag() != null) && ...

            if ((oUDDIEntity.getCategoryBag() != null)
                && (oUDDIEntity.getCategoryBag().getKeyedReference() != null)
                && (oUDDIEntity.getCategoryBag().getKeyedReference().size() > 0)) {
              // Public Key
              // -----------
              List<String> oPublicKeys =
                  findAndGetValueFromKeyedReference(
                      oUDDIEntity.getCategoryBag().getKeyedReference(), PUBLIC_KEY_ID_KEY);
              if (oPublicKeys != null && oPublicKeys.size() == 1) {
                for (String sValue : oPublicKeys) {
                  if ((sValue != null) && (sValue.length() > 0)) {
                    oEntity.setPublicKey(sValue);
                  }
                }
              } else {
                log.debug(
                    "A single Public Key value is NOT detected for UDDI Entity "
                        + oUDDIEntity.getBusinessKey());
              }
              // State names
              // ------------
              List<String> oStateNames =
                  findAndGetValueFromKeyedReference(
                      oUDDIEntity.getCategoryBag().getKeyedReference(), STATE_NAME_ID_KEY);
              if (oStateNames != null && oStateNames.size() > 0) {
                CMStates oStates = new CMStates();
                List<String> oStatesList = oStates.getState();
                for (String sValue : oStateNames) {
                  if ((sValue != null) && (sValue.length() > 0)) {
                    oStatesList.add(sValue);
                  }
                }
                oEntity.setStates(oStates);
              } else {
                log.debug(
                    "No State name is detected for UDDI Entity " + oUDDIEntity.getBusinessKey());
              }
            }
          } // if (oEntity != nulll)
        } // if ((oUDDIEntity.getBusinessKey() != null) && (oUDDIEntity.getBusinessKey().length() >
          // 0))
      } // for (BusinessEntity oUDDIEntity : oResult.getBusinessEntity())
    } // if ((oResult != null) &&
  }