Package org.picketlink.idm.common.exception

Examples of org.picketlink.idm.common.exception.IdentityException


  
   protected void configureRelationships() throws IdentityException
   {
      if (relationshipClass == null)
      {
         throw new IdentityException("Error initializing JpaIdentityStore - relationshipClass not set.");
      }
     
      List<Property<Object>> props = PropertyQueries.createQuery(relationshipClass)
         .addCriteria(new TypedPropertyCriteria(identityClass))
         .addCriteria(new PropertyTypeCriteria(PropertyType.RELATIONSHIP_FROM))
         .getResultList();
     
      if (props.size() == 1)
      {
         modelProperties.put(PROPERTY_RELATIONSHIP_FROM, props.get(0));
      }
      else if (props.size() > 1)
      {
         throw new IdentityException(
               "Ambiguous relationshipFrom property in relationship class " +
               relationshipClass.getName());
      }
      else
      {
         Property<Object> p = findNamedProperty(relationshipClass, "relationshipFrom",
               "fromIdentityObject", "fromIdentity");
         if (p != null)
         {
            modelProperties.put(PROPERTY_RELATIONSHIP_FROM, p);
         }
         else
         {
            // Last resort - search for a property with a type of identityClass
            // and a "from" in its name
            props = PropertyQueries.createQuery(relationshipClass)
               .addCriteria(new TypedPropertyCriteria(identityClass))
               .getResultList();
           
            for (Property<Object> prop : props)
            {
               if (prop.getName().contains("from"))
               {
                  modelProperties.put(PROPERTY_RELATIONSHIP_FROM, prop);
                  break;
               }
            }
         }        
      }
 
     
      props = PropertyQueries.createQuery(relationshipClass)
         .addCriteria(new TypedPropertyCriteria(identityClass))
         .addCriteria(new PropertyTypeCriteria(PropertyType.RELATIONSHIP_TO))
         .getResultList();
  
      if (props.size() == 1)
      {
         modelProperties.put(PROPERTY_RELATIONSHIP_TO, props.get(0));
      }
      else if (props.size() > 1)
      {
         throw new IdentityException(
               "Ambiguous relationshipTo property in relationship class " +
               relationshipClass.getName());
      }
      else
      {
         Property<Object> p = findNamedProperty(relationshipClass, "relationshipTo",
               "toIdentityObject", "toIdentity");
         if (p != null)
         {
            modelProperties.put(PROPERTY_RELATIONSHIP_TO, p);
         }
         else
         {
            // Last resort - search for a property with a type of identityClass
            // and a "to" in its name
            props = PropertyQueries.createQuery(relationshipClass)
               .addCriteria(new TypedPropertyCriteria(identityClass))
               .getResultList();
           
            for (Property<Object> prop : props)
            {
               if (prop.getName().contains("to"))
               {
                  modelProperties.put(PROPERTY_RELATIONSHIP_TO, prop);
                  break;
               }
            }
         }        
      }     
     
      props = PropertyQueries.createQuery(relationshipClass)
         .addCriteria(new PropertyTypeCriteria(PropertyType.TYPE))
         .getResultList();
      if (props.size() == 1)
      {
         modelProperties.put(PROPERTY_RELATIONSHIP_TYPE, props.get(0));
      }
      else if (props.size() > 1)
      {
         throw new IdentityException(
               "Ambiguous relationshipType property in relationship class " +
               relationshipClass.getName());
      }
      else
      {
         Property<Object> p = findNamedProperty(relationshipClass,
               "identityRelationshipType", "relationshipType", "type");
         if (p != null)
         {
            modelProperties.put(PROPERTY_RELATIONSHIP_TYPE, p);
         }
         else
         {
            props = PropertyQueries.createQuery(relationshipClass)
               .getResultList();
            for (Property<Object> prop : props)
            {
               if (prop.getName().contains("type"))
               {
                  modelProperties.put(PROPERTY_RELATIONSHIP_TYPE, prop);
                  break;
               }
            }
         }
      }
     
      props = PropertyQueries.createQuery(relationshipClass)
         .addCriteria(new PropertyTypeCriteria(PropertyType.NAME))
         .addCriteria(new TypedPropertyCriteria(String.class))
         .getResultList();
     
      if (props.size() == 1)
      {
         modelProperties.put(PROPERTY_RELATIONSHIP_NAME, props.get(0));
      }
      else if (props.size() > 1)
      {
         throw new IdentityException(
               "Ambiguous relationship name property in relationship class " +
               relationshipClass.getName());
      }
      else
      {
         Property<Object> p = findNamedProperty(relationshipClass,
               "relationshipName", "name");
         if (p != null)
         {
            modelProperties.put(PROPERTY_RELATIONSHIP_NAME, p);
         }
      }
     
      if (!modelProperties.containsKey(PROPERTY_RELATIONSHIP_FROM))
      {
         throw new IdentityException(
            "Error initializing JpaIdentityStore - no valid relationship from property found.");
      }
     
      if (!modelProperties.containsKey(PROPERTY_RELATIONSHIP_TO))
      {
         throw new IdentityException(
            "Error initializing JpaIdentityStore - no valid relationship to property found.");
      }
     
      if (!modelProperties.containsKey(PROPERTY_RELATIONSHIP_TYPE))
      {
         throw new IdentityException(
            "Error initializing JpaIdentityStore - no valid relationship type property found.");
      }
     
      if (!modelProperties.containsKey(PROPERTY_RELATIONSHIP_NAME))
      {
         throw new IdentityException(
            "Error initializing JpaIdentityStore - no valid relationship name property found.");
      }
     
      Class<?> typeClass = modelProperties.get(PROPERTY_RELATIONSHIP_TYPE).getJavaClass();
      if (!String.class.equals(typeClass))
      {
         props = PropertyQueries.createQuery(typeClass)
            .addCriteria(new PropertyTypeCriteria(PropertyType.NAME))
            .addCriteria(new TypedPropertyCriteria(String.class))
            .getResultList();
        
         if (props.size() == 1)
         {
            modelProperties.put(PROPERTY_RELATIONSHIP_TYPE_NAME, props.get(0));
         }
         else if (props.size() > 1)
         {
            throw new IdentityException(
                  "Ambiguous relationship type name property in class " +
                  typeClass.getName());
         }
         else
         {
            Property<Object> p = findNamedProperty(typeClass, "relationshipTypeName",
                  "typeName", "name");
            if (p != null)
            {
               modelProperties.put(PROPERTY_RELATIONSHIP_TYPE_NAME, p);
            }
         }
        
         if (!modelProperties.containsKey(PROPERTY_RELATIONSHIP_TYPE_NAME))
         {
            throw new IdentityException(
                  "Error initializing JpaIdentityStore - no valid relationship type name property found");
         }
      }     
   }
View Full Code Here


         {
            modelProperties.put(PROPERTY_ATTRIBUTE_NAME, props.get(0));
         }
         else if (props.size() > 1)
         {
            throw new IdentityException(
                "Ambiguous attribute name property in class " +
                attributeClass.getName());
         }
         else
         {
            Property<Object> prop = findNamedProperty(attributeClass,
                  "attributeName", "name");
            if (prop != null) modelProperties.put(PROPERTY_ATTRIBUTE_NAME, prop);
         }
        
         props = PropertyQueries.createQuery(attributeClass)
            .addCriteria(new PropertyTypeCriteria(PropertyType.VALUE))
            .getResultList();
        
         if (props.size() == 1)
         {
            modelProperties.put(PROPERTY_ATTRIBUTE_VALUE, props.get(0));
         }
         else if (props.size() > 1)
         {
            throw new IdentityException(
                  "Ambiguous attribute value property in class " +
                  attributeClass.getName());
         }
         else
         {
            Property<Object> prop = findNamedProperty(attributeClass,
                  "attributeValue", "value");
            if (prop != null) modelProperties.put(PROPERTY_ATTRIBUTE_VALUE, prop);
         }
        
         props = PropertyQueries.createQuery(attributeClass)
            .addCriteria(new TypedPropertyCriteria(identityClass))
            .getResultList();
        
         if (props.size() == 1)
         {
            modelProperties.put(PROPERTY_ATTRIBUTE_IDENTITY, props.get(0));
         }
         else if (props.size() > 1)
         {
            throw new IdentityException(
                  "Ambiguous identity property in attribute class " +
                  attributeClass.getName());
         }
         else
         {
            throw new IdentityException("Error initializing JpaIdentityStore - " +
                  "no attribute identity property found.");
         }
        
         props = PropertyQueries.createQuery(attributeClass)
            .addCriteria(new PropertyTypeCriteria(PropertyType.TYPE))
            .getResultList();
        
         if (props.size() == 1)
         {
            modelProperties.put(PROPERTY_ATTRIBUTE_TYPE, props.get(0));
         }
         else if (props.size() > 1)
         {
            throw new IdentityException(
                  "Ambiguous attribute type property in class " +
                  attributeClass.getName());
         }
      }
View Full Code Here

         return obj;
      }
      catch (Exception ex)
      {
         throw new IdentityException("Error creating identity object", ex);
      }   
   }
View Full Code Here

         return new IdentityObjectRelationshipImpl(fromIdentity, toIdentity,
               relationshipName, relationshipType);
      }
      catch (Exception ex)
      {
         throw new IdentityException("Exception creating relationship", ex);
      }
   }
View Full Code Here

         em.persist(roleTypeInstance);
         return name;
      }
      catch (Exception ex)
      {
         throw new IdentityException("Error creating relationship name", ex);
      }
   }
View Full Code Here

        
         em.remove(instance);
      }
      catch (NoResultException ex)
      {
         throw new IdentityException(String.format(
               "Exception removing identity object - [%s] not found.",
               identity), ex);
      }
   }
View Full Code Here

              
               em.persist(newCredential);
            }
            catch (IllegalAccessException ex)
            {
               throw new IdentityException("Error updating credential - could " +
                     "not create credential instance", ex);
            }
            catch (InstantiationException ex)
            {
               throw new IdentityException("Error updating credential - could " +
                     "not create credential instance", ex);
            }
         }
         else
         {
View Full Code Here

            }
         }
      }
      catch (Exception e)
      {
         throw new IdentityException("Error while adding attributes.", e);
      }     
   }
View Full Code Here

                        attributeValueProp.setValue(attribute, ((Double) value).toString());
                        attributeTypeProp.setValue(attribute, ATTRIBUTE_TYPE_DOUBLE);
                     }
                     else
                     {
                        throw new IdentityException("Could not persist attribute value - unsupported attribute value type " +
                              value.getClass());
                     }
                  }
                  else
                  {
                     attributeValueProp.setValue(attribute, value.toString());
                  }
                 
                  em.persist(attribute);  
               }
            }
         }
      }
      catch (Exception e)
      {
         throw new IdentityException("Error while updating attributes.", e);
      }
   }
View Full Code Here

TOP

Related Classes of org.picketlink.idm.common.exception.IdentityException

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.