Package org.apache.juddi.datastore

Examples of org.apache.juddi.datastore.DataStore


    AuthInfo authInfo = request.getAuthInfo();
    Vector bindingVector = request.getBindingTemplateVector();
    UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();

    // Aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      // Validate authentication parameters
      Publisher publisher = getPublisher(authInfo,dataStore);
      String publisherID = publisher.getPublisherID();

      // Validate request parameters
      for (int i=0; i<bindingVector.size(); i++)
      {
        // Move the BindingTemplate into a form we can work with easily
        BindingTemplate binding = (BindingTemplate)bindingVector.elementAt(i);
        String serviceKey = binding.getServiceKey();
        String bindingKey = binding.getBindingKey();

        // Confirm that the 'BusinessService' that this binding belongs to
        // really exists. If not then throw an InvalidKeyPassedException.
       if ((serviceKey == null) || (serviceKey.length() == 0) || (!dataStore.isValidServiceKey(serviceKey)))
          throw new InvalidKeyPassedException("ServiceKey: "+serviceKey);

        // Confirm that 'publisherID' controls the BusinessService that this
        // binding template belongs to.  If not then throw a UserMismatchException.
        if (!dataStore.isServicePublisher(serviceKey,publisherID))
          throw new UserMismatchException("ServiceKey: "+serviceKey);

        // If a BindingKey was specified then make sure it's a valid one.
        if ((bindingKey != null) && (bindingKey.length() > 0) && (!dataStore.isValidBindingKey(bindingKey)))
          throw new InvalidKeyPassedException("BindingKey: "+bindingKey);

        // Normally, a valid tModelKey MUST be specified for the keyedReference
        // to be valid. However, in the case of a keyedReference that is used in
        // a categoryBag, the tModelKey may be omitted or specified as a
        // zero-length string to indicate that the taxonomy being used is
        // uddi-org:general_keywords. When it is omitted in this manner, the UDDI
        // registry will insert the proper key during the save_xx operation.
        // - UDDI Programmers API v2.04 Section 4.3.5.1 Specifying keyedReferences
        //
        CategoryBag categoryBag = binding.getCategoryBag();
        if (categoryBag != null)
        {
          Vector keyedRefVector = categoryBag.getKeyedReferenceVector();
          if (keyedRefVector != null)
          {
            int vectorSize = keyedRefVector.size();
            if (vectorSize > 0)
            {
              for (int j=0; j<vectorSize; j++)
              {
                KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(j);
                String key = keyedRef.getTModelKey();
               
                // A null or zero-length tModelKey is treated as
                // though the tModelKey for uddiorg:general_keywords
                // had been specified.
                //
                if ((key == null) || (key.trim().length() == 0))
                  keyedRef.setTModelKey(TModel.GENERAL_KEYWORDS_TMODEL_KEY);
              }
            }
          }
        }
      }

      for (int i=0; i<bindingVector.size(); i++)
      {
        // move the BindingTemplate data into a form we can work with easily
        BindingTemplate binding = (BindingTemplate)bindingVector.elementAt(i);
        String bindingKey = binding.getBindingKey();

        // If the new BindingTemplate has a BindingKey then it must already
        // exists so delete the old one. It a BindingKey isn't specified then
        // this is a new BindingTemplate so create a new BindingKey for it.
        if ((bindingKey != null) && (bindingKey.length() > 0))
          dataStore.deleteBinding(bindingKey);
        else
          binding.setBindingKey(uuidgen.uuidgen());

        // everything checks out so let's save it.
        dataStore.saveBinding(binding);
      }

      dataStore.commit();

      BindingDetail detail = new BindingDetail();
      detail.setGeneric(generic);
      detail.setOperator(Config.getOperator());
      detail.setTruncated(false);
      detail.setBindingTemplateVector(bindingVector);
      return detail;
    }
    catch(InvalidKeyPassedException ikpex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(ikpex);
      throw (RegistryException)ikpex;
    }
    catch(UserMismatchException umex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(umex);
      throw (RegistryException)umex;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }
  }
View Full Code Here


    String generic = request.getGeneric();
    AuthInfo authInfo = request.getAuthInfo();
    Vector publisherVector = request.getPublisherVector();

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      // validate authentication parameters
      Publisher publisher = getPublisher(authInfo,dataStore);
      String publisherID = publisher.getPublisherID();

      // Only a user with administrative access can create new publishers
      if (!dataStore.isAdministrator(publisherID))
        throw new RegistryException("Invalid Operation, You must have " +
          "administrative priveledges to create a new publisher account.");
     
      // validate request parameters
      for (int i=0; i<publisherVector.size(); i++)
      {
        // move the Publisher into a form we can work with easily
        Publisher pub = (Publisher)publisherVector.elementAt(i);
        String pubID = pub.getPublisherID();

        // Make sure a PublisherID was specified.
        if ((pubID == null) || (pubID.length() == 0))
          throw new RegistryException("A valid Publisher ID was " +
            "not specified: "+pubID);
      }

      for (int i=0; i<publisherVector.size(); i++)
      {
        // move the Publisher into a form we can work with easily
        Publisher pub = (Publisher)publisherVector.elementAt(i);
        String pubID = pub.getPublisherID();

        // if the publisher account arleady exists then delete it.
        dataStore.deletePublisher(pubID);

        // Everything checks out so let's save it.
        dataStore.savePublisher(pub);
      }

      dataStore.commit();

      PublisherDetail detail = new PublisherDetail();
      detail.setGeneric(generic);
      detail.setOperator(Config.getOperator());
      detail.setTruncated(false);
      detail.setPublisherVector(publisherVector);
      return detail;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }
  }
View Full Code Here

    String generic = request.getGeneric();
    AuthInfo authInfo = request.getAuthInfo();
    Vector publisherIDVector = request.getPublisherIDVector();

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      // validate authentication parameters
      Publisher publisher = getPublisher(authInfo,dataStore);
      String publisherID = publisher.getPublisherID();

      if (!dataStore.isAdministrator(publisherID))
        throw new RegistryException("Invalid Operation, You must have " +
          "administrative priveledges to delete a publisher account.");

      // validate request parameters
      for (int i=0; i<publisherIDVector.size(); i++)
      {
        // grab the next key from the vector
        String pubID = (String)publisherIDVector.elementAt(i);

        if (pubID.equalsIgnoreCase(publisherID))
          throw new RegistryException("Invalid Operation, A publisher " +
            "cannot delete it's own publisher account.");

        // TModel exists and we control it so let's delete it.
        dataStore.deletePublisher(pubID);
      }

      // delete the TModels
      for (int i=0; i<publisherIDVector.size(); i++)
      {
        String tModelKey = (String)publisherIDVector.elementAt(i);
        dataStore.deleteTModel(tModelKey);

        log.info("Publisher '"+publisherID+"' deleted TModel with key: "+tModelKey);
      }

      dataStore.commit();
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }

    // didn't encounter an exception so let's create
    // and return a successfull DispositionReport
    DispositionReport dispRpt = new DispositionReport();
View Full Code Here

    String generic = request.getGeneric();
    String userID = request.getUserID();
    String cred = request.getCredential();

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    // aquire a jUDDI Authenticator instance
    Authenticator authenticator = AuthenticatorFactory.getAuthenticator();

    try
    {
      // begin this transaction
      dataStore.beginTrans();

      // authenticate the requestor's credentials
      String publisherID = authenticator.authenticate(userID,cred);
      if (publisherID == null)
        throw new UnknownUserException("user ID: "+userID);

      // ensure the user has the authority to publish
      Publisher publisher = dataStore.getPublisher(publisherID);
      if (publisher == null)
        throw new UnknownUserException("user ID: "+userID);

      // generate a new token (optionally using publisher info)
      String token = dataStore.generateToken(publisher);

      // save auth token value to persistent storage
      dataStore.storeAuthToken(token,publisher);

      // commit this transaction
      dataStore.commit();

      // create, populate and return an AuthToken object
      AuthToken authToken = new AuthToken();
      authToken.setGeneric(generic);
      authToken.setOperator(Config.getOperator());
      authToken.setAuthInfo(new AuthInfo(token));
      return authToken;
    }
    catch(UnknownUserException ukuex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(ukuex.getMessage());
      throw (RegistryException)ukuex;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }
  }
View Full Code Here

    GetBusinessDetail request = (GetBusinessDetail)regObject;
    String generic = request.getGeneric();
    Vector businessKeyVector = request.getBusinessKeyVector();

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      for (int i=0; i<businessKeyVector.size(); i++)
      {
        String businessKey = (String)businessKeyVector.elementAt(i);

        // If the a BusinessEntity doesn't exist throw an InvalidKeyPassedException.
        if ((businessKey == null) || (businessKey.length() == 0) ||
            (!dataStore.isValidBusinessKey(businessKey)))
          throw new InvalidKeyPassedException(businessKey);
      }

      Vector businessVector = new Vector();

      for (int i=0; i<businessKeyVector.size(); i++)
      {
        String businessKey = (String)businessKeyVector.elementAt(i);
        businessVector.addElement(dataStore.fetchBusiness(businessKey));
      }

      dataStore.commit();

      // create a new BusinessDetail and stuff the new businessVector into it.
      BusinessDetail detail = new BusinessDetail();
      detail.setGeneric(generic);
      detail.setOperator(Config.getOperator());
      detail.setBusinessEntityVector(businessVector);
      return detail;
    }
    catch(InvalidKeyPassedException keyex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(keyex.getMessage());
      throw (RegistryException)keyex;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      dataStore.release();
    }
  }
View Full Code Here

    if ((uploadRegVector != null) && (uploadRegVector.size() > 0))
      throw new UnsupportedException("Saving BusinessEntities via " +
        "UploadRegistry is not supported.");

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      // validate authentication parameters
      Publisher publisher = getPublisher(authInfo,dataStore);

      String publisherID = publisher.getPublisherID();
      String authorizedName = publisher.getName();

      // validate request parameters & execute
      for (int i=0; i<businessVector.size(); i++)
      {
        // move the BusinessEntity into a form we can work with easily
        BusinessEntity business = (BusinessEntity)businessVector.elementAt(i);

        String businessKey = business.getBusinessKey();

        // If a BusinessKey was specified then make sure it's a valid one.
        if ((businessKey != null) && (businessKey.length() > 0) && (!dataStore.isValidBusinessKey(businessKey)))
          throw new InvalidKeyPassedException("businessKey="+businessKey);

        // If a BusinessKey was specified then make sure 'publisherID' controls it.
        if ((businessKey != null) && (businessKey.length() > 0) && (!dataStore.isBusinessPublisher(businessKey,publisherID)))
          throw new UserMismatchException("businessKey="+businessKey);
      }

      for (int i=0; i<businessVector.size(); i++)
      {
        // move the BusinessEntity into a form we can work with easily
        BusinessEntity business = (BusinessEntity)businessVector.elementAt(i);

        String businessKey = business.getBusinessKey();

        // If the new BusinessEntity has a BusinessKey then it must already
        // exists so delete the old one. It a BusinessKey isn't specified then
        // this is a new BusinessEntity so create a new BusinessKey for it.
        if ((businessKey != null) && (businessKey.length() > 0))
        {
          dataStore.deleteBusiness(businessKey);
        }
        else
        {
           business.setBusinessKey(uuidgen.uuidgen());
        }

        // check if the business has DiscoveryURL with
        // useType as 'businessEntity' if not create one
        // and add it to the business object.

        addBusinessEntityDiscoveryURL(business);

        // Everything checks out so let's save it. First
        // store 'authorizedName' and 'operator' values
        // in each BusinessEntity.

        business.setAuthorizedName(authorizedName);
        business.setOperator(Config.getOperator());

        // If no contacts were specified with the Business
        // Entity then add a new contact of type 'publisher'
        // using the publishers information.

        Contacts contacts = business.getContacts();
        if ((contacts == null) ||
            (contacts.getContactVector() == null) ||
            (contacts.getContactVector().isEmpty()))
        {
          Contact contact = new Contact();
          contact.setPersonNameValue(publisher.getName());
          contact.setUseType("publisher");

          String workPhone = publisher.getWorkPhone();
          if (workPhone != null)
            contact.addPhone(new Phone(workPhone,"business"));

          String mobile = publisher.getMobilePhone();
          if (mobile != null)
            contact.addPhone(new Phone(mobile,"mobile"));

          String pager = publisher.getPager();
          if (pager != null)
            contact.addPhone(new Phone(pager,"pager"));

          String email = publisher.getEmailAddress();
          if (email != null)
            contact.addEmail(new Email(email,"email"));

          business.addContact(contact);
        }

        dataStore.saveBusiness(business,publisherID);
      }

      dataStore.commit();

      BusinessDetail detail = new BusinessDetail();
      detail.setGeneric(generic);
      detail.setOperator(Config.getOperator());
      detail.setTruncated(false);
      detail.setBusinessEntityVector(businessVector);
      return detail;
    }
    catch(UnsupportedException suppex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(suppex);
      throw (RegistryException)suppex;
    }
    catch(InvalidKeyPassedException ikpex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(ikpex);
      throw (RegistryException)ikpex;
    }
    catch(UserMismatchException umex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(umex);
      throw (RegistryException)umex;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }
  }
View Full Code Here

      list.setTruncated(false);
      return list;
    }

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      // validate the 'name' parameters as much as possible up-front before
      // calling into the data layer for relational validation.
      if (nameVector != null)
      {
        // only allowed to specify a maximum of 5 names (implementation
        // dependent).  This value is configurable in jUDDI.
        int maxNames = Config.getMaxNameElementsAllowed();
        if ((nameVector != null) && (nameVector.size() > maxNames))
          throw new TooManyOptionsException("max=" + maxNames);

        // names can not exceed the maximum character length specified by the
        // UDDI specification (v2.0 specifies a max character length of 255). This
        // value is configurable in jUDDI.
        int maxNameLength = Config.getMaxNameLengthAllowed();
        for (int i = 0; i < nameVector.size(); i++)
        {
          String name = ((Name) nameVector.elementAt(i)).getValue();
          if (name.length() > maxNameLength)
            throw new NameTooLongException(name +
                "(max=" + maxNameLength + ")");
        }
      }

      // validate the 'qualifiers' parameter as much as possible up-front before
      // calling into the data layer for relational validation.
      if (qualifiers != null)
      {
        Vector qVector = qualifiers.getFindQualifierVector();
        if ((qVector!=null) && (qVector.size() > 0))
        {
          for (int i = 0; i < qVector.size(); i++)
          {
            FindQualifier qualifier = (FindQualifier) qVector.elementAt(i);
            String qValue = qualifier.getValue();

            if ((!qValue.equals(FindQualifier.EXACT_NAME_MATCH))
              && (!qValue.equals(FindQualifier.CASE_SENSITIVE_MATCH))
              && (!qValue.equals(FindQualifier.OR_ALL_KEYS))
              && (!qValue.equals(FindQualifier.OR_LIKE_KEYS))
              && (!qValue.equals(FindQualifier.AND_ALL_KEYS))
              && (!qValue.equals(FindQualifier.SORT_BY_NAME_ASC))
              && (!qValue.equals(FindQualifier.SORT_BY_NAME_DESC))
              && (!qValue.equals(FindQualifier.SORT_BY_DATE_ASC))
              && (!qValue.equals(FindQualifier.SORT_BY_DATE_DESC))
              && (!qValue.equals(FindQualifier.SERVICE_SUBSET))
              && (!qValue
                .equals(FindQualifier.COMBINE_CATEGORY_BAGS)))
              throw new UnsupportedException(
                "findQualifier=" + qValue);
          }
        }
      }

      Vector infoVector = null;
      boolean truncatedResults = false;

      // perform the search for matching business entities (returns only business keys in the order requested)
      Vector keyVector =
        dataStore.findBusiness(
          nameVector,
          discoveryURLs,
          identifierBag,
          categoryBag,
          tModelBag,
          qualifiers);
      if ((keyVector != null) && (keyVector.size() > 0))
      {
        // if a maxRows value has been specified and it's less than
        // the number of rows we are about to return then only return
        // maxRows specified.
        int rowCount = keyVector.size();
        if ((maxRows > 0) && (maxRows < rowCount))
        {
          rowCount = maxRows;
          truncatedResults = true;
        }

        // iterate through the business entity keys fetching
        // each associated BusinessInfo in sequence.
        infoVector = new Vector(rowCount);
        for (int i = 0; i < rowCount; i++)
          infoVector.addElement(
            dataStore.fetchBusinessInfo(
              (String) keyVector.elementAt(i)));
      }

      dataStore.commit();

      // create a new BusinessInfos instance and stuff
      // the new Vector of BusinessInfos into it.
      BusinessInfos infos = new BusinessInfos();
      infos.setBusinessInfoVector(infoVector);

      // create a new BusinessList instance and stuff
      // the new businessInfos instance into it.
      BusinessList list = new BusinessList();
      list.setBusinessInfos(infos);
      list.setGeneric(generic);
      list.setOperator(Config.getOperator());
      list.setTruncated(truncatedResults);
      return list;
    }
    catch(TooManyOptionsException tmoex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(tmoex.getMessage());
      throw (RegistryException)tmoex;
    }
    catch(NameTooLongException ntlex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(ntlex.getMessage());
      throw (RegistryException)ntlex;
    }
    catch(UnsupportedException suppex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(suppex.getMessage());
      throw (RegistryException)suppex;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }
  }
View Full Code Here

    GetBindingDetail request = (GetBindingDetail)regObject;
    String generic = request.getGeneric();
    Vector keyVector = request.getBindingKeyVector();

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      for (int i=0; i<keyVector.size(); i++)
      {
        // grab the next key from the vector
        String key = (String)keyVector.elementAt(i);

        // check that this binding template really exists.
        // If not then throw an InvalidKeyPassedException.
        if ((key == null) || (key.length() == 0) ||
            (!dataStore.isValidBindingKey(key)))
          throw new InvalidKeyPassedException(key);
      }

      Vector bindingVector = new Vector();

      for (int i=0; i<keyVector.size(); i++)
      {
        String key = (String)keyVector.elementAt(i);
        bindingVector.add(dataStore.fetchBinding(key));
      }

      dataStore.commit();

      // create a new BindingDetail and stuff the new bindingVector into it.
      BindingDetail detail = new BindingDetail();
      detail.setGeneric(generic);
      detail.setBindingTemplateVector(bindingVector);
      detail.setOperator(Config.getOperator());
      return detail;
    }
    catch(InvalidKeyPassedException keyex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(keyex.getMessage());
      throw (RegistryException)keyex;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }
  }
View Full Code Here

    String generic = request.getGeneric();
    AuthInfo authInfo = request.getAuthInfo();
    Vector assertionVector = request.getPublisherAssertionVector();

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      // validate authentication parameters
      Publisher publisher = getPublisher(authInfo,dataStore);
      String publisherID = publisher.getPublisherID();

      // validate request parameters & execute
      // nothing that requires validation has been identified

      // set the PublisherAssertions
      Vector savedAssertionsVector = dataStore.setAssertions(publisherID,assertionVector);

      dataStore.commit();

      PublisherAssertions assertions = new PublisherAssertions();
      assertions.setGeneric(generic);
      assertions.setOperator(Config.getOperator());
      assertions.setPublisherAssertionVector(savedAssertionsVector);
      return assertions;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }
  }
View Full Code Here

    GetRegisteredInfo request = (GetRegisteredInfo)regObject;
    String generic = request.getGeneric();
    AuthInfo authInfo = request.getAuthInfo();

    // aquire a jUDDI datastore instance
    DataStore dataStore = DataStoreFactory.getDataStore();

    try
    {
      dataStore.beginTrans();

      // validate authentication parameters
      Publisher publisher = getPublisher(authInfo,dataStore);
      String publisherID = publisher.getPublisherID();

      // validate request parameters
      // nothing that requires validation has been identified

      // declare some 'work' variables
      BusinessInfos businessInfos = new BusinessInfos();
      TModelInfos tModelInfos = new TModelInfos();
      Vector keyVector = null;
      Vector infoVector = null;

      // perform the search for BusinessEntities registered to publisherID
      keyVector = dataStore.findRegisteredBusinesses(publisherID);
      if ((keyVector != null) && (keyVector.size() > 0))
      {
        int rowCount = keyVector.size();

        // iterate through the business entity keys fetching each associated BusinessInfo.
        infoVector = new Vector(rowCount);
        for (int i=0; i<rowCount; i++)
          infoVector.addElement(dataStore.fetchBusinessInfo((String)keyVector.elementAt(i)));

        businessInfos.setBusinessInfoVector(infoVector);
      }

      // perform the search for TModels registered to publisherID
      keyVector = dataStore.findRegisteredTModels(publisherID);
      if ((keyVector != null) && (keyVector.size() > 0))
      {
        int rowCount = keyVector.size();

        // iterate through the tModel keys fetching each associated TModelInfo.
        infoVector = new Vector(rowCount);
        for (int i=0; i<rowCount; i++)
          infoVector.addElement(dataStore.fetchTModelInfo((String)keyVector.elementAt(i)));

        tModelInfos.setTModelInfoVector(infoVector);
      }

      dataStore.commit();

      // create a new BusinessInfos instance and stuff
      // the new Vector of BusinessInfos into it.
      RegisteredInfo info = new RegisteredInfo();
      info.setGeneric(generic);
      info.setOperator(Config.getOperator());
      info.setBusinessInfos(businessInfos);
      info.setTModelInfos(tModelInfos);
      return info;
    }
    catch(RegistryException regex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(regex);
      throw (RegistryException)regex;
    }
    catch(Exception ex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.error(ex);
      throw new RegistryException(ex);
    }
    finally
    {
      if (dataStore != null)
        dataStore.release();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.juddi.datastore.DataStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.