Package org.apache.juddi.v3.error

Examples of org.apache.juddi.v3.error.ErrorMessage


  }

  public void validateTModel(EntityManager em, org.uddi.api_v3.TModel tModel, Configuration config) throws DispositionReportFaultMessage {
    // A supplied tModel can't be null
    if (tModel == null)
      throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.NullInput"));
   
    boolean entityExists = false;
    String entityKey = tModel.getTModelKey();
    if (entityKey == null || entityKey.length() == 0) {
      KeyGenerator keyGen = KeyGeneratorFactory.getKeyGenerator();
      entityKey = keyGen.generate();
      tModel.setTModelKey(entityKey);
    }
    else {
      // Per section 4.4: keys must be case-folded
      entityKey = entityKey.toLowerCase();
      tModel.setTModelKey(entityKey);
     
      Object obj = em.find(org.apache.juddi.model.Tmodel.class, entityKey);
      if (obj != null) {
        entityExists = true;

        // Make sure publisher owns this entity.
        if (!publisher.isOwner((UddiEntity)obj))
          throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey));
      }
      else {
        // Inside this block, we have a key proposed by the publisher on a new entity
       
        // First test to see if this is a Key Generator tModel. The keyGenerator suffix appearing in the key is the indicator, since this is not
        // allowed *unless* it's a key generator.
        if (entityKey.toUpperCase().contains(KeyGenerator.KEYGENERATOR_SUFFIX.toUpperCase())) {
          ValidateUDDIKey.validateUDDIv3KeyGeneratorTModel(tModel);
         
          // The root publisher is only allowed one key generator.  This is published in the installation.
          String rootPublisherStr = "root";
          try {
            rootPublisherStr = AppConfig.getConfiguration().getString(Property.JUDDI_ROOT_PUBLISHER);
          } catch (ConfigurationException ce) {
            log.error("Could not read the root publisher setting in the configuration.");
          }
          if (publisher.getAuthorizedName().equals(rootPublisherStr))
            throw new FatalErrorException(new ErrorMessage("errors.tmodel.keygenerator.RootKeyGen"));
         
          // It's a valid Key Generator, but is it available for this publisher?
          if (!publisher.isKeyGeneratorAvailable(em, entityKey))
            throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.BadPartition", entityKey));
       
        }
        else {
          // If not a key generator, then simply validate key and then check to see that the proposed key is valid for this publisher
          ValidateUDDIKey.validateUDDIv3Key(entityKey);
          if (!publisher.isValidPublisherKey(em, entityKey))
            throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.BadPartition", entityKey));
        }
      }
    }

    if (!entityExists) {
      // Check to make sure key isn't used by another entity.
      if (!isUniqueKey(em, entityKey))
        throw new KeyUnavailableException(new ErrorMessage("errors.keyunavailable.KeyExists", entityKey));
    }
   
    // TODO: validate "checked" categories or category groups (see section 5.2.3 of spec)? optional to support
   
    if (tModel.getName() == null)
      throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.NoName"));
   
    validateCategoryBag(tModel.getCategoryBag(), config);
    validateIdentifierBag(tModel.getIdentifierBag(), config);

    List<org.uddi.api_v3.OverviewDoc> overviewDocList = tModel.getOverviewDoc();
View Full Code Here


  }
 
  public void validatePublisherAssertion(EntityManager em, org.uddi.api_v3.PublisherAssertion pubAssertion) throws DispositionReportFaultMessage {
    // A supplied publisher assertion can't be null
    if (pubAssertion == null)
      throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.NullInput"));
   
    // The keyedRef must not be blank and every field must contain data.
    org.uddi.api_v3.KeyedReference keyedRef = pubAssertion.getKeyedReference();
    if (keyedRef == null ||
      keyedRef.getTModelKey() == null || keyedRef.getTModelKey().length() == 0 ||
      keyedRef.getKeyName() == null || keyedRef.getKeyName().length() == 0 ||
      keyedRef.getKeyValue() == null || keyedRef.getKeyValue().length() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.BlankKeyedRef"));
   
    String fromKey = pubAssertion.getFromKey();
    if (fromKey == null || fromKey.length() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.BlankFromKey"));

    String toKey = pubAssertion.getToKey();
    if (toKey == null || toKey.length() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.BlankToKey"));
   
    if (fromKey.equalsIgnoreCase(toKey))
      throw new ValueNotAllowedException(new ErrorMessage("errors.pubassertion.SameBusinessKey"));
   
    Object fromObj = em.find(org.apache.juddi.model.BusinessEntity.class, fromKey);
    if (fromObj == null)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", fromKey));

    Object toObj = em.find(org.apache.juddi.model.BusinessEntity.class, pubAssertion.getToKey());
    if (toObj == null)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", toKey));
   
    if (!publisher.isOwner((UddiEntity)fromObj) && !publisher.isOwner((UddiEntity)toObj))
      throw new UserMismatchException(new ErrorMessage("errors.pubassertion.UserMismatch", fromKey + " & " + toKey));
     
  }
View Full Code Here

  }
 
  public void validateNames(List<org.uddi.api_v3.Name> names) throws DispositionReportFaultMessage {
    // At least one name is required
    if (names == null || names.size() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.names.NoInput"));
   
    for (Name n : names) {
      if (n.getValue() == null || n.getValue().length() == 0)
        throw new ValueNotAllowedException(new ErrorMessage("errors.names.NoValue"));
    }
   
  }
View Full Code Here

      return;
   
    // If contacts do exist, at least one contact is required
    List<org.uddi.api_v3.Contact> contactList = contacts.getContact();
    if (contactList == null || contactList.size() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.contacts.NoInput"));
   
    for (org.uddi.api_v3.Contact contact : contactList) {
      validateContact(contact);
    }
   
View Full Code Here

  }

  public void validateContact(org.uddi.api_v3.Contact contact) throws DispositionReportFaultMessage {
    // A supplied contact can't be null
    if (contact == null)
      throw new ValueNotAllowedException(new ErrorMessage("errors.contact.NullInput"));
   
    // At least one personName is required
    List<org.uddi.api_v3.PersonName> pnameList = contact.getPersonName();
    if (pnameList == null || pnameList.size() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.contact.NoPersonName"));
   
    List<org.uddi.api_v3.Address> addressList = contact.getAddress();
    if (addressList != null) {
      for (org.uddi.api_v3.Address address : addressList) {
        if (address != null) {
          if (address.getAddressLine() == null || address.getAddressLine().size() == 0)
            throw new ValueNotAllowedException(new ErrorMessage("errors.contact.NoAddressLine"));
        }
      }
    }
  }
View Full Code Here

      return;

    // If discUrls does exist, it must have at least one element
    List<org.uddi.api_v3.DiscoveryURL> discUrlList = discUrls.getDiscoveryURL();
    if (discUrlList == null || discUrlList.size() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.discurls.NoInput"));
 
View Full Code Here

   
    // If category bag does exist, it must have at least one element
    List<KeyedReference> elems = categories.getKeyedReference();
    List<KeyedReferenceGroup> groups = categories.getKeyedReferenceGroup();
    if (groups.size() == 0 && elems.size() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.categorybag.NoInput"));
   
    for (Object elem : elems) {
      if (elem instanceof org.uddi.api_v3.KeyedReference) {
        validateKeyedReference((KeyedReference) elem, config);
      }
View Full Code Here

      return;
   
    // If category bag does exist, it must have at least one element
    List<org.uddi.api_v3.KeyedReference> keyedRefList = identifiers.getKeyedReference();
    if (keyedRefList == null || keyedRefList.size() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.identifierbag.NoInput"));
   
    for (org.uddi.api_v3.KeyedReference keyedRef : keyedRefList) {
      validateKeyedReference(keyedRef, config);
    }
  }
View Full Code Here

 

  public void validateKeyedReferenceGroup(KeyedReferenceGroup krg) throws DispositionReportFaultMessage {
    // Keyed reference groups must contain a tModelKey
    if (krg.getTModelKey() == null || krg.getTModelKey().length() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoTModelKey"));
  }
View Full Code Here

      throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoTModelKey"));
  }
 
  public void validateKeyedReference(KeyedReference kr, Configuration config) throws DispositionReportFaultMessage {
    if (kr.getTModelKey() == null || kr.getTModelKey().length() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoTModelKey"));
     
    if (kr.getKeyValue() == null || kr.getKeyValue().length() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NoKeyValue"));
     
    String rootPublisherStr = config.getString(Property.JUDDI_ROOT_PUBLISHER);
    // Per section 6.2.2.1 of the specification, no publishers (except the root) are allowed to use the node categorization tmodelKey
    if (Constants.NODE_CATEGORY_TMODEL.equalsIgnoreCase(kr.getTModelKey())) {
      if (!rootPublisherStr.equals(publisher.getAuthorizedName()))
        throw new ValueNotAllowedException(new ErrorMessage("errors.keyedreference.NodeCategoryTModel", Constants.NODE_CATEGORY_TMODEL));
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.juddi.v3.error.ErrorMessage

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.