Package org.apache.juddi.datastore

Examples of org.apache.juddi.datastore.DataStore


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

    // 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
      for (int i=0; i<assertionVector.size(); i++)
      {
        // transform each PublisherAssertion data into a form we can work with easily
        PublisherAssertion assertion = (PublisherAssertion)assertionVector.elementAt(i);

        // make sure we've got a 'fromKey'
        String fromKey = assertion.getFromKey();
        if ((fromKey == null) || (fromKey.length() == 0))
          throw new InvalidKeyPassedException("fromKey="+fromKey);

        // make sure we've got a 'toKey'
        String toKey = assertion.getToKey();
        if ((toKey == null) || (toKey.length() == 0))
          throw new InvalidKeyPassedException("toKey="+toKey);

        // make sure we've got a 'KeyedRefernce'
        KeyedReference keyedRef = assertion.getKeyedReference();
        if (keyedRef == null)
          throw new InvalidKeyPassedException("keyedRef="+keyedRef);

        // make sure the 'KeyedRefernce' contains a 'TModelKey'
        String tModelKey = keyedRef.getTModelKey();
        if ((tModelKey == null) || (tModelKey.length() == 0))
          throw new InvalidKeyPassedException("tModelKey="+keyedRef);

        // verify that the BusinessEntities or tModel identified by the 'fromKey'
        // really exists. If not then throw an InvalidKeyPassedException.
        if ((!dataStore.isValidBusinessKey(fromKey)) && (!dataStore.isValidTModelKey(fromKey)))
          throw new InvalidKeyPassedException("fromKey="+fromKey);

        // verify that the BusinessEntitys or tModel identified by the 'fromKey'
        // really exists. If not then throw an InvalidKeyPassedException.
        if ((!dataStore.isValidBusinessKey(toKey)) && (!dataStore.isValidTModelKey(toKey)))
          throw new InvalidKeyPassedException("toKey="+toKey);

        // verify that the 'publisherID' controls at least one of the
        // BusinessEntities or TModels that are identified in this
        // assertion. If not then throw a UserMismatchException.
        if ((!dataStore.isBusinessPublisher(fromKey,publisherID)) &&
            (!dataStore.isBusinessPublisher(toKey,publisherID))   &&
            (!dataStore.isTModelPublisher(fromKey,publisherID))   &&
            (!dataStore.isTModelPublisher(toKey,publisherID)))
          throw new UserMismatchException("fromKey="+fromKey+" toKey="+toKey);
      }

      dataStore.saveAssertions(publisherID,assertionVector);
      dataStore.commit();
    }
    catch(InvalidKeyPassedException keyex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(keyex.getMessage());
      throw (RegistryException)keyex;
    }
    catch(UserMismatchException 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();
    }

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


    GetTModelDetail request = (GetTModelDetail)regObject;
    String generic = request.getGeneric();
    Vector keyVector = request.getTModelKeyVector();

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

    try
    {
      dataStore.beginTrans();

      for (int i=0; i<keyVector.size(); i++)
      {
        String tModelKey = (String)keyVector.elementAt(i);

        // If the a TModel doesn't exist hrow an InvalidKeyPassedException.
        if ((tModelKey == null) || (tModelKey.length() == 0) ||
            (!dataStore.isValidTModelKey(tModelKey)))
          throw new InvalidKeyPassedException(tModelKey);
      }

      Vector tModelVector = new Vector();

      for (int i=0; i<keyVector.size(); i++)
      {
        String tModelKey = (String)keyVector.elementAt(i);
        tModelVector.add(dataStore.fetchTModel(tModelKey));
      }

      dataStore.commit();

      // create a new TModelDetail and stuff the new tModelVector into it.
      TModelDetail detail = new TModelDetail();
      detail.setGeneric(generic);
      detail.setTModelVector(tModelVector);
      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

    if ((uploadRegVector != null) && (uploadRegVector.size() > 0))
      throw new UnsupportedException("Saving TModels 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
      for (int i=0; i<tModelVector.size(); i++)
      {
        // move the TModel into a form we can work with easily
        TModel tModel = (TModel)tModelVector.elementAt(i);
        String tModelKey = tModel.getTModelKey();

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

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

      for (int i=0; i<tModelVector.size(); i++)
      {
        // move the TModel into a form we can work with easily
        TModel tModel = (TModel)tModelVector.elementAt(i);
        String tModelKey = tModel.getTModelKey();

        // If the new TModel has a TModelKey then it must already exists
        // so delete the old one. It a TModelKey isn't specified then
        // this is a new TModel so create a new TModelKey for it.
        if ((tModelKey != null) && (tModelKey.length() > 0))
          dataStore.deleteTModel(tModelKey);
        else
          tModel.setTModelKey("uuid:"+uuidgen.uuidgen());

        // Everything checks out so let's save it. First store
        // 'authorizedName' and 'operator' values in each TModel.
        tModel.setAuthorizedName(authorizedName);
        tModel.setOperator(Config.getOperator());
        dataStore.saveTModel(tModel,publisherID);
      }

      dataStore.commit();

      TModelDetail detail = new TModelDetail();
      detail.setGeneric(generic);
      detail.setOperator(Config.getOperator());
      detail.setTruncated(false);
      detail.setTModelVector(tModelVector);
      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

    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);
      }

      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

    KeyedReference keyedRef = request.getKeyedReference();
    FindQualifiers qualifiers = request.getFindQualifiers();
    int maxRows = request.getMaxRows();

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

    try
    {
      dataStore.beginTrans();

      Vector infoVector = null;
      boolean truncatedResults = false;

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

      // perform the search for matching business entities (return only keys in requested order)
      infoVector = dataStore.findRelatedBusinesses(businessKey,keyedRef,qualifiers);
      if ((infoVector != null) && (infoVector.size() > 0))
      {
        // if the number of keys returned is greater than maxRows then truncate the results.
        int rowCount = infoVector.size();
        if ((maxRows > 0) && (maxRows < rowCount))
        {
          rowCount = maxRows;
          truncatedResults = true;
        }
      }

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

      dataStore.commit();

      // create a new RelatedBusinessesList instance and
      // stuff the new relatedBusinessInfoVector into it.
      RelatedBusinessesList list = new RelatedBusinessesList();
      list.setGeneric(generic);
      list.setOperator(Config.getOperator());
      list.setTruncated(truncatedResults);
      list.setRelatedBusinessInfos(infos);
      return list;
    }
    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 serviceKeyVector = request.getServiceKeyVector();

    // 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<serviceKeyVector.size(); i++)
      {
        // grab the next key from the vector
        String serviceKey = (String)serviceKeyVector.elementAt(i);

        // check that this business server really exists.
        // If not then throw an InvalidKeyPassedException.
        if ((serviceKey == null) || (serviceKey.length() == 0) ||
            (!dataStore.isValidServiceKey(serviceKey)))
          throw new InvalidKeyPassedException(serviceKey);

        // check to make sure that 'authorizedName' controls the
        // business entity that this server belongs to. If not
        // then throw a UserMismatchException.
        if (!dataStore.isServicePublisher(serviceKey,publisherID))
          throw new UserMismatchException("serviceKey="+serviceKey);
      }

      // delete the BusinessServices
      for (int i=0; i<serviceKeyVector.size(); i++)
      {
        String serviceKey = (String)serviceKeyVector.elementAt(i);
        dataStore.deleteService(serviceKey);

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

      dataStore.commit();
    }
    catch(InvalidKeyPassedException keyex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(keyex.getMessage());
      throw (RegistryException)keyex;
    }
    catch(UserMismatchException umex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(umex.getMessage());
      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();
    }

    // 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();
    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
      for (int i=0; i<assertionVector.size(); i++)
      {
        // nothing that requires validation has been identified
      }

      // delete the PublisherAssertions
      dataStore.deleteAssertions(publisherID,assertionVector);
      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

      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_names= "+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 services (return only keys in requested order)
      Vector keyVector = dataStore.findService(businessKey,nameVector,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 server keys fetching
        // each associated ServiceInfo in sequence.
        infoVector = new Vector(rowCount);
        for (int i=0; i<rowCount; i++)
          infoVector.addElement(dataStore.fetchServiceInfo((String)keyVector.elementAt(i)));
      }

      dataStore.commit();

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

      // create a new ServiceList instance and stuff
      // the new serviceInfos instance into it.
      ServiceList list = new ServiceList();
      list.setGeneric(generic);
      list.setServiceInfos(infos);
      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

    GetPublisherDetail request = (GetPublisherDetail)regObject;
    String generic = request.getGeneric();
    Vector idVector = request.getPublisherIDVector();

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

    try
    {
      dataStore.beginTrans();

      for (int i=0; i<idVector.size(); i++)
      {
        String publisherID = (String)idVector.elementAt(i);

        // If the a Publisher doesn't exist hrow an UnknownUserException.
        if ((publisherID == null) || (publisherID.length() == 0) ||
            (dataStore.getPublisher(publisherID) == null))
          throw new UnknownUserException("PublisherID: "+publisherID);
      }

      Vector publisherVector = new Vector();

      for (int i=0; i<idVector.size(); i++)
      {
        String publisherID = (String)idVector.elementAt(i);
        publisherVector.add(dataStore.getPublisher(publisherID));
      }

      dataStore.commit();

      // create a new PublisherDetail and stuff the new tModelVector into it.
      PublisherDetail detail = new PublisherDetail();
      detail.setGeneric(generic);
      detail.setPublisherVector(publisherVector);
      detail.setOperator(Config.getOperator());
      return detail;
    }
    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

      detail.setTruncated(false);
      return detail;
    }

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

    try
    {
      dataStore.beginTrans();

      // a find_binding request MUST include a service_key attribute
      if ((serviceKey == null) || (serviceKey.length() == 0))
        throw new InvalidKeyPassedException("serviceKey="+serviceKey);

      // 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 bindingVector = null;
      boolean truncatedResults = false;

      // perform the search for matching binding templates (return only keys in requested order)
      Vector keyVector = dataStore.findBinding(serviceKey,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 binding templates keys fetching
        // each associated BindingTemplate in sequence.
        bindingVector = new Vector(rowCount);
        for (int i=0; i<rowCount; i++)
          bindingVector.addElement(dataStore.fetchBinding((String)keyVector.elementAt(i)));
      }

      dataStore.commit();

      // create a new BindingDetail instance and stuff
      // the new bindingTemplateVector into it.
      BindingDetail detail = new BindingDetail();
      detail.setBindingTemplateVector(bindingVector);
      detail.setGeneric(generic);
      detail.setOperator(Config.getOperator());
      detail.setTruncated(truncatedResults);
      return detail;
    }
    catch(InvalidKeyPassedException keyex)
    {
      try { dataStore.rollback(); } catch(Exception e) { }
      log.info(keyex.getMessage());
      throw (RegistryException)keyex;
    }
    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

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.