Package org.apache.juddi.error

Examples of org.apache.juddi.error.ErrorMessage


*/
public class ValidateUDDIKey {

  public static void validateUDDIv3Key(String key) throws DispositionReportFaultMessage {
    if (key == null)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NullKey"));
   
    String keyToTest = key.trim();
    if (keyToTest.endsWith(KeyGenerator.PARTITION_SEPARATOR))
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));

    StringTokenizer tokenizer = new StringTokenizer(key.toLowerCase(), KeyGenerator.PARTITION_SEPARATOR);
    int tokensCount = tokenizer.countTokens();
    if(tokensCount <= 1)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
    for(int count = 0; tokenizer.hasMoreTokens(); count++) {
      String nextToken = tokenizer.nextToken();

      if (count == 0) {
        if (!ValidateUDDIKey.isValidUDDIScheme(nextToken))
          throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
      }
      else if (count == 1) {
        if(!ValidateUDDIKey.isValidDomainKey(nextToken))
          throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
      }
      else {
        if (!isValidKSS(nextToken))
          throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.MalformedKey", key));
      }
    }
  }
View Full Code Here


    }
  }
 
  public static void validateUDDIv3KeyGeneratorKey(String key) throws DispositionReportFaultMessage {
    if (key == null)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NullKeys"));
   
    if ( !(key.toUpperCase().endsWith(KeyGenerator.KEYGENERATOR_SUFFIX.toUpperCase())) )
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.KeyGenSuffix", key));
   
    validateUDDIv3Key(key.substring(0, key.lastIndexOf(KeyGenerator.PARTITION_SEPARATOR)));
  }
View Full Code Here

    validateUDDIv3Key(key.substring(0, key.lastIndexOf(KeyGenerator.PARTITION_SEPARATOR)));
  }
 
  public static void validateUDDIv3KeyGeneratorTModel(org.uddi.api_v3.TModel tModel) throws DispositionReportFaultMessage {
    if (tModel == null)
      throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.NullInput"));
   
    validateUDDIv3KeyGeneratorKey(tModel.getTModelKey());

    // A key generator key should have exactly one category and it's key value should be 'keyGenerator'
    org.uddi.api_v3.CategoryBag categories = tModel.getCategoryBag();
    if (categories != null) {
      List<org.uddi.api_v3.KeyedReference> elems = categories.getKeyedReference();
      if (elems != null && elems.size() == 1) {
        org.uddi.api_v3.KeyedReference elem = elems.get(0);
        if (elem != null) {
          if (elem != null && elem instanceof org.uddi.api_v3.KeyedReference) {
            String keyedValue = ((org.uddi.api_v3.KeyedReference)elem).getKeyValue();
            if (keyedValue != null) {
              if (keyedValue.equalsIgnoreCase(KeyGenerator.KEYGENERATOR_SUFFIX))
                return;
            }
          }
        }
      }
    }

    throw new ValueNotAllowedException(new ErrorMessage("errors.tmodel.keygenerator.BadCategory"));
  }
View Full Code Here

  }
 
  public void validateDiscardTransferToken(EntityManager em, DiscardTransferToken body) throws DispositionReportFaultMessage {
    // No null input
    if (body == null)
      throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
   
    KeyBag keyBag = body.getKeyBag();
   
    // The call must contain at least a transfer token or keyBag
    if (body.getTransferToken() == null && keyBag == null)
      throw new FatalErrorException(new ErrorMessage("errors.discardtransfertoken.NoInput"));
   
    if (keyBag != null) {
      List<String> keyList = keyBag.getKey();
      if (keyList == null || keyList.size() == 0)
        throw new ValueNotAllowedException(new ErrorMessage("errors.keybag.NoInput"));
     
      // Test that publisher owns keys using operational info.
      for (String key : keyList) {
        UddiEntity uddiEntity = em.find(UddiEntity.class, key);
       
        // According to spec, it's ok if a key doesn't match any known entities, it will just be ignored.  However, the publisher must own
        // the entity in order to discard the associated token.
        if (uddiEntity != null) {
          if (!publisher.isOwner(uddiEntity))
            throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", key));
         
        }
      }
   
    }
View Full Code Here

 
  public void validateGetTransferToken(EntityManager em, KeyBag keyBag) throws DispositionReportFaultMessage {

    // No null input
    if (keyBag == null)
      throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
   
    List<String> keyList = keyBag.getKey();
    if (keyList == null || keyList.size() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.keybag.NoInput"));
   
    // Test that publisher owns keys using operational info.
    Vector<DynamicQuery.Parameter> params = new Vector<DynamicQuery.Parameter>(0);
    for (String key : keyList) {
      UddiEntity uddiEntity = em.find(UddiEntity.class, key);
     
      if (uddiEntity == null)
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.EntityNotFound", key));
     
      // Only BusinessEntities or TModels are allowed to be transferred
      if (!(uddiEntity instanceof org.apache.juddi.model.BusinessEntity) &&
        !(uddiEntity instanceof org.apache.juddi.model.Tmodel))
        throw new InvalidKeyPassedException(new ErrorMessage("errors.gettransfertoken.InvalidEntity", key));
     
      if (!publisher.isOwner(uddiEntity))
        throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", key));
     
      // Creating parameters for key-checking query
      DynamicQuery.Parameter param = new DynamicQuery.Parameter("UPPER(ttk.entityKey)",
                                    key.toUpperCase(),
                                    DynamicQuery.PREDICATE_EQUALS);
      params.add(param);

    }

    // Make sure keys aren't implicated in another transfer request
    DynamicQuery checkKeysQry = new DynamicQuery();
    checkKeysQry.append("select ttk.entityKey from TransferTokenKey ttk ");
    checkKeysQry.WHERE().pad().appendGroupedOr(params.toArray(new DynamicQuery.Parameter[0]));

    Query qry = checkKeysQry.buildJPAQuery(em);
    List<?> obj = qry.getResultList();
    if (obj != null && obj.size() > 0)
      throw new TokenAlreadyExistsException(new ErrorMessage("errors.gettransfertoken.KeyExists", (String)obj.get(0)));

  }
View Full Code Here

 
  public void validateTransferEntities(EntityManager em, TransferEntities body) throws DispositionReportFaultMessage {

    // No null input
    if (body == null)
      throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
   
    org.uddi.custody_v3.TransferToken apiTransferToken = body.getTransferToken();
    if (apiTransferToken == null)
      throw new FatalErrorException(new ErrorMessage("errors.transfertoken.NullInput"));
   
    KeyBag keyBag = body.getKeyBag();
    if (keyBag == null)
      throw new FatalErrorException(new ErrorMessage("errors.keybag.NullInput"));
   
    List<String> apiKeyList = keyBag.getKey();
    if (apiKeyList == null || apiKeyList.size() == 0)
      throw new ValueNotAllowedException(new ErrorMessage("errors.keybag.NoInput"));
   
    String transferTokenId = new String(apiTransferToken.getOpaqueToken());
    org.apache.juddi.model.TransferToken modelTransferToken = em.find(org.apache.juddi.model.TransferToken.class, transferTokenId);
    if (modelTransferToken == null)
      throw new TransferNotAllowedException(new ErrorMessage("errors.transferentities.TokenNotFound", transferTokenId));
   
    Date now = new Date();
    if (now.after(modelTransferToken.getExpirationDate()))
      throw new TransferNotAllowedException(new ErrorMessage("errors.transferentities.TokenExpired", transferTokenId));
   
    List<TransferTokenKey> transferKeyList = modelTransferToken.getTransferKeys();
    List<String> modelKeyList = new ArrayList<String>(0);
    if (transferKeyList != null && transferKeyList.size() > 0) {
      for (TransferTokenKey ttk : transferKeyList)
        modelKeyList.add(ttk.getEntityKey());
    }
   
    // The keys in the supplied key bag must match exactly the keys in the stored transfer and the entities must exist
    Collections.sort(apiKeyList);
    Collections.sort(modelKeyList);
    int count = 0;
    for (String key : apiKeyList) {
      if (!key.equalsIgnoreCase(modelKeyList.get(count)))
        throw new TransferNotAllowedException(new ErrorMessage("errors.transferentities.KeyMismatch", key + " & " + modelKeyList.get(count)));
     
      UddiEntity uddiEntity = em.find(UddiEntity.class, key);
      if (uddiEntity == null)
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.EntityNotFound", key));
     
      count++;
    }

  }
View Full Code Here

    if (relatedBusinessInfos == null)
      relatedBusinessInfos = new org.uddi.api_v3.RelatedBusinessInfos();
   
    org.apache.juddi.model.BusinessEntity focalBusiness = em.find(org.apache.juddi.model.BusinessEntity.class, focalKey);
    if (focalBusiness == null)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", focalKey));

    List<org.apache.juddi.model.PublisherAssertion> pubAssertList = null;
    if (direction == Direction.FROM_KEY)
      pubAssertList = focalBusiness.getPublisherAssertionsForFromKey();
    else
View Full Code Here

  public void validateDeleteBusiness(EntityManager em, DeleteBusiness body) throws DispositionReportFaultMessage {

    // No null input
    if (body == null)
      throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
   
    // No null or empty list
    List<String> entityKeyList = body.getBusinessKey();
    if (entityKeyList == null || entityKeyList.size() == 0)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));

    HashSet<String> dupCheck = new HashSet<String>();
    for (String entityKey : entityKeyList) {
      boolean inserted = dupCheck.add(entityKey);
      if (!inserted)
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
     
      Object obj = em.find(org.apache.juddi.model.BusinessEntity.class, entityKey);
      if (obj == null)
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BusinessNotFound", entityKey));
     
      if (!publisher.isOwner((UddiEntity)obj))
        throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey));
     
    }
  }
View Full Code Here

  public void validateDeleteService(EntityManager em, DeleteService body) throws DispositionReportFaultMessage {

    // No null input
    if (body == null)
      throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
   
    // No null or empty list
    List<String> entityKeyList = body.getServiceKey();
    if (entityKeyList == null || entityKeyList.size() == 0)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));

    HashSet<String> dupCheck = new HashSet<String>();
    for (String entityKey : entityKeyList) {
      boolean inserted = dupCheck.add(entityKey);
      if (!inserted)
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
     
      Object obj = em.find(org.apache.juddi.model.BusinessService.class, entityKey);
      if (obj == null)
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.ServiceNotFound", entityKey));
     
      if (!publisher.isOwner((UddiEntity)obj))
        throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey));
     
    }
  }
View Full Code Here

  public void validateDeleteBinding(EntityManager em, DeleteBinding body) throws DispositionReportFaultMessage {

    // No null input
    if (body == null)
      throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
   
    // No null or empty list
    List<String> entityKeyList = body.getBindingKey();
    if (entityKeyList == null || entityKeyList.size() == 0)
      throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NoKeys"));

    // Checking for duplicates and existence
    HashSet<String> dupCheck = new HashSet<String>();
    for (String entityKey : entityKeyList) {
      boolean inserted = dupCheck.add(entityKey);
      if (!inserted)
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.DuplicateKey", entityKey));
     
      Object obj = em.find(org.apache.juddi.model.BindingTemplate.class, entityKey);
      if (obj == null)
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.BindingTemplateNotFound", entityKey));
     
      if (!publisher.isOwner((UddiEntity)obj))
        throw new UserMismatchException(new ErrorMessage("errors.usermismatch.InvalidOwner", entityKey));

    }
  }
View Full Code Here

TOP

Related Classes of org.apache.juddi.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.