public void createEntityDescriptor(String realm,EntityDescriptorElement entityDescriptor) throws IDFFMetaException {
  String classMethod="IDFFMetaManager.createEntityDescriptor:";
  String entityId=null;
  if (entityDescriptor == null) {
    LogUtil.error(Level.INFO,LogUtil.NULL_ENTITY_DESCRIPTOR,null);
    throw new IDFFMetaException("nullEntityDescriptor",null);
  }
 else {
    entityId=entityDescriptor.getProviderID();
    if (entityId == null) {
      debug.error(classMethod + "Entity ID is null");
      LogUtil.error(Level.INFO,LogUtil.NULL_ENTITY_ID,null);
      throw new IDFFMetaException("nullEntityID",null);
    }
  }
  if ((realm == null) || (realm.length() == 0)) {
    realm=ROOT_REALM;
  }
  String[] args={entityId,realm};
  EntityDescriptorElement descriptor=getEntityDescriptor(realm,entityId);
  if (descriptor != null) {
    List idps=descriptor.getIDPDescriptor();
    boolean hasIDP=(idps != null) && !idps.isEmpty();
    List sps=descriptor.getSPDescriptor();
    boolean hasSP=(sps != null) && !sps.isEmpty();
    List newIDPs=entityDescriptor.getIDPDescriptor();
    List newSPs=entityDescriptor.getSPDescriptor();
    if ((newIDPs != null) && !newIDPs.isEmpty() && hasIDP) {
      LogUtil.error(Level.INFO,LogUtil.SET_ENTITY_FAILED,args);
      throw new IDFFMetaException("idpAlreadyExisted",args);
    }
    if ((newSPs != null) && !newSPs.isEmpty() && hasSP) {
      LogUtil.error(Level.INFO,LogUtil.SET_ENTITY_FAILED,args);
      throw new IDFFMetaException("spAlreadyExisted",args);
    }
    idps.addAll(newIDPs);
    sps.addAll(newSPs);
    setEntityDescriptor(realm,descriptor);
  }
 else {
    try {
      Map attrs=IDFFMetaUtils.convertJAXBToAttrMap(IDFF_METADATA_ATTR,entityDescriptor);
      if (debug.messageEnabled()) {
        debug.message(classMethod + attrs);
      }
      idffMetaConfigInstance.createConfiguration(realm,entityId,attrs);
      LogUtil.access(Level.INFO,LogUtil.CREATE_ENTITY_SUCCEEDED,args);
    }
 catch (    ConfigurationException ce) {
      debug.error("Cannot create entity descriptor",ce);
      LogUtil.error(Level.INFO,LogUtil.CREATE_ENTITY_FAILED,args);
      throw new IDFFMetaException(ce);
    }
catch (    UnsupportedOperationException uoe) {
      debug.error("Creating EntityDescriptor : Unsupported operation");
      LogUtil.error(Level.INFO,LogUtil.UNSUPPORTED_OPERATION,null);
      throw new IDFFMetaException("unsupportedOperation",null);
    }
catch (    JAXBException jaxbe) {
      debug.error(classMethod,jaxbe);
      LogUtil.error(Level.INFO,LogUtil.INVALID_ENTITY_DESCRIPTOR,args);
      throw new IDFFMetaException("invalidEntityDescriptor",args);
    }
  }
}

public void createEntityDescriptor ( String realm , EntityDescriptorElement entityDescriptor ) throws IDFFMetaException { String classMethod = "IDFFMetaManager.createEntityDescriptor:" ; String entityId = null ; if ( entityDescriptor == null ) { LogUtil . error ( Level . INFO , LogUtil . NULL_ENTITY_DESCRIPTOR , null ) ; throw new IDFFMetaException ( "nullEntityDescriptor" , null ) ; } else { entityId = entityDescriptor . getProviderID ( ) ; if ( entityId == null ) { debug . error ( classMethod + "Entity ID is null" ) ; LogUtil . error ( Level . INFO , LogUtil . NULL_ENTITY_ID , null ) ; throw new IDFFMetaException ( "nullEntityID" , null ) ; } } if ( ( realm == null ) || ( realm . length ( ) == 0 ) ) { realm = ROOT_REALM ; } String [ ] args = { entityId , realm } ; EntityDescriptorElement descriptor = getEntityDescriptor ( realm , entityId ) ; if ( descriptor != null ) { List idps = descriptor . getIDPDescriptor ( ) ; boolean hasIDP = ( idps != null ) && ! idps . isEmpty ( ) ; List sps = descriptor . getSPDescriptor ( ) ; boolean hasSP = ( sps != null ) && ! sps . isEmpty ( ) ; List newIDPs = entityDescriptor . getIDPDescriptor ( ) ; List newSPs = entityDescriptor . getSPDescriptor ( ) ; if ( ( newIDPs != null ) && ! newIDPs . isEmpty ( ) && hasIDP ) { LogUtil . error ( Level . INFO , LogUtil . SET_ENTITY_FAILED , args ) ; throw new IDFFMetaException ( "idpAlreadyExisted" , args ) ; } if ( ( newSPs != null ) && ! newSPs . isEmpty ( ) && hasSP ) { LogUtil . error ( Level . INFO , LogUtil . SET_ENTITY_FAILED , args ) ; throw new IDFFMetaException ( "spAlreadyExisted" , args ) ; } idps . addAll ( newIDPs ) ; sps . addAll ( newSPs ) ; setEntityDescriptor ( realm , descriptor ) ; } else { try { Map attrs = IDFFMetaUtils . convertJAXBToAttrMap ( IDFF_METADATA_ATTR , entityDescriptor ) ; if ( debug . messageEnabled ( ) ) { debug . message ( classMethod + attrs ) ; } idffMetaConfigInstance . createConfiguration ( realm , entityId , attrs ) ; LogUtil . access ( Level . INFO , LogUtil . CREATE_ENTITY_SUCCEEDED , args ) ; } catch ( ConfigurationException ce ) { debug . error ( "Cannot create entity descriptor" , ce ) ; LogUtil . error ( Level . INFO , LogUtil . CREATE_ENTITY_FAILED , args ) ; throw new IDFFMetaException ( ce ) ; } catch ( UnsupportedOperationException uoe ) { debug . error ( "Creating EntityDescriptor : Unsupported operation" ) ; LogUtil . error ( Level . INFO , LogUtil . UNSUPPORTED_OPERATION , null ) ; throw new IDFFMetaException ( "unsupportedOperation" , null ) ; } catch ( JAXBException jaxbe ) { debug . error ( classMethod , jaxbe ) ; LogUtil . error ( Level . INFO , LogUtil . INVALID_ENTITY_DESCRIPTOR , args ) ; throw new IDFFMetaException ( "invalidEntityDescriptor" , args ) ; } } }
creates the standard metadata entity descriptor . the metadata is created under the realm .
