public void assignServices(Map serviceNamesAndAttr,boolean store) throws AMException, SSOException {
  if (!((profileType == AMObject.ORGANIZATION) || (profileType == AMObject.USER) || (profileType == AMObject.STATIC_GROUP)|| (profileType == AMObject.DYNAMIC_GROUP)|| (profileType == AMObject.ORGANIZATIONAL_UNIT)|| (profileType == AMObject.ASSIGNABLE_DYNAMIC_GROUP)|| (profileType == AMObject.GROUP))) {
    throw new UnsupportedOperationException();
  }
  if ((serviceNamesAndAttr == null) || serviceNamesAndAttr.isEmpty()) {
    return;
  }
  Set newOCs=new HashSet();
  Set canAssign=new HashSet();
  if (store) {
    Set assignedServices=getAssignedServices();
    Set toAssign=serviceNamesAndAttr.keySet();
    Iterator it=toAssign.iterator();
    while (it.hasNext()) {
      String thisService=(String)it.next();
      if (!assignedServices.contains(thisService)) {
        canAssign.add(thisService);
      }
 else {
        if (debug.warningEnabled()) {
          debug.warning("AMObjectImpl.assignService()-> " + thisService + " is already assigned to "+ entryDN);
        }
      }
    }
    Set registered=null;
    if (profileType == ORGANIZATION) {
      registered=dsServices.getRegisteredServiceNames(null,entryDN);
    }
 else {
      registered=dsServices.getRegisteredServiceNames(null,getOrganizationDN());
    }
    it=canAssign.iterator();
    while (it.hasNext()) {
      if (!registered.contains((String)it.next())) {
        throw new AMException(AMSDKBundle.getString("126",locale),"126");
      }
    }
  }
 else {
    canAssign=serviceNamesAndAttr.keySet();
  }
  newOCs=AMServiceUtils.getServiceObjectClasses(token,canAssign);
  if (store) {
    Set oldOCs=getAttribute("objectclass");
    newOCs=AMCommonUtils.combineOCs(newOCs,oldOCs);
  }
  setAttribute("objectclass",newOCs);
  Iterator it=canAssign.iterator();
  while (it.hasNext()) {
    String thisService=(String)it.next();
    Map attrMap=(Map)serviceNamesAndAttr.get(thisService);
    if ((attrMap == null) || attrMap.isEmpty()) {
      attrMap=new HashMap();
    }
    try {
      ServiceSchemaManager ssm=new ServiceSchemaManager(thisService,token);
      ServiceSchema ss=null;
      Object args[]={thisService};
      if (profileType == AMObject.USER) {
        ss=ssm.getSchema(SchemaType.USER);
        if (ss == null) {
          ss=ssm.getSchema(SchemaType.DYNAMIC);
        }
      }
 else       if ((profileType == AMObject.ORGANIZATION) || (profileType == AMObject.ORGANIZATIONAL_UNIT)) {
        ss=ssm.getSchema(SchemaType.DOMAIN);
      }
 else       if ((profileType == AMObject.STATIC_GROUP) || (profileType == AMObject.DYNAMIC_GROUP) || (profileType == AMObject.ASSIGNABLE_DYNAMIC_GROUP)|| (profileType == AMObject.GROUP)) {
        ss=ssm.getSchema(SchemaType.GROUP);
      }
      if (ss == null) {
        debug.warning(AMSDKBundle.getString("1001"));
        throw new AMException(AMSDKBundle.getString("1001",args,locale),"1001",args);
      }
      if (ss.getServiceType() != SchemaType.DYNAMIC) {
        attrMap=ss.validateAndInheritDefaults(attrMap,true);
      }
      attrMap=AMCommonUtils.removeEmptyValues(attrMap);
    }
 catch (    SMSException smse) {
      debug.error("AMObjectImpl:assignService-> " + "unable to validate attributes for " + thisService,smse);
      throw new AMException(AMSDKBundle.getString("908",locale),"908");
    }
    setAttributes(attrMap);
  }
  if (store) {
    store();
  }
}

public void assignServices ( Map serviceNamesAndAttr , boolean store ) throws AMException , SSOException { if ( ! ( ( profileType == AMObject . ORGANIZATION ) || ( profileType == AMObject . USER ) || ( profileType == AMObject . STATIC_GROUP ) || ( profileType == AMObject . DYNAMIC_GROUP ) || ( profileType == AMObject . ORGANIZATIONAL_UNIT ) || ( profileType == AMObject . ASSIGNABLE_DYNAMIC_GROUP ) || ( profileType == AMObject . GROUP ) ) ) { throw new UnsupportedOperationException ( ) ; } if ( ( serviceNamesAndAttr == null ) || serviceNamesAndAttr . isEmpty ( ) ) { return ; } Set newOCs = new HashSet ( ) ; Set canAssign = new HashSet ( ) ; if ( store ) { Set assignedServices = getAssignedServices ( ) ; Set toAssign = serviceNamesAndAttr . keySet ( ) ; Iterator it = toAssign . iterator ( ) ; while ( it . hasNext ( ) ) { String thisService = ( String ) it . next ( ) ; if ( ! assignedServices . contains ( thisService ) ) { canAssign . add ( thisService ) ; } else { if ( debug . warningEnabled ( ) ) { debug . warning ( "AMObjectImpl.assignService()-> " + thisService + " is already assigned to " + entryDN ) ; } } } Set registered = null ; if ( profileType == ORGANIZATION ) { registered = dsServices . getRegisteredServiceNames ( null , entryDN ) ; } else { registered = dsServices . getRegisteredServiceNames ( null , getOrganizationDN ( ) ) ; } it = canAssign . iterator ( ) ; while ( it . hasNext ( ) ) { if ( ! registered . contains ( ( String ) it . next ( ) ) ) { throw new AMException ( AMSDKBundle . getString ( "126" , locale ) , "126" ) ; } } } else { canAssign = serviceNamesAndAttr . keySet ( ) ; } newOCs = AMServiceUtils . getServiceObjectClasses ( token , canAssign ) ; if ( store ) { Set oldOCs = getAttribute ( "objectclass" ) ; newOCs = AMCommonUtils . combineOCs ( newOCs , oldOCs ) ; } setAttribute ( "objectclass" , newOCs ) ; Iterator it = canAssign . iterator ( ) ; while ( it . hasNext ( ) ) { String thisService = ( String ) it . next ( ) ; Map attrMap = ( Map ) serviceNamesAndAttr . get ( thisService ) ; if ( ( attrMap == null ) || attrMap . isEmpty ( ) ) { attrMap = new HashMap ( ) ; } try { ServiceSchemaManager ssm = new ServiceSchemaManager ( thisService , token ) ; ServiceSchema ss = null ; Object args [ ] = { thisService } ; if ( profileType == AMObject . USER ) { ss = ssm . getSchema ( SchemaType . USER ) ; if ( ss == null ) { ss = ssm . getSchema ( SchemaType . DYNAMIC ) ; } } else if ( ( profileType == AMObject . ORGANIZATION ) || ( profileType == AMObject . ORGANIZATIONAL_UNIT ) ) { ss = ssm . getSchema ( SchemaType . DOMAIN ) ; } else if ( ( profileType == AMObject . STATIC_GROUP ) || ( profileType == AMObject . DYNAMIC_GROUP ) || ( profileType == AMObject . ASSIGNABLE_DYNAMIC_GROUP ) || ( profileType == AMObject . GROUP ) ) { ss = ssm . getSchema ( SchemaType . GROUP ) ; } if ( ss == null ) { debug . warning ( AMSDKBundle . getString ( "1001" ) ) ; throw new AMException ( AMSDKBundle . getString ( "1001" , args , locale ) , "1001" , args ) ; } if ( ss . getServiceType ( ) != SchemaType . DYNAMIC ) { attrMap = ss . validateAndInheritDefaults ( attrMap , true ) ; } attrMap = AMCommonUtils . removeEmptyValues ( attrMap ) ; } catch ( SMSException smse ) { debug . error ( "AMObjectImpl:assignService-> " + "unable to validate attributes for " + thisService , smse ) ; throw new AMException ( AMSDKBundle . getString ( "908" , locale ) , "908" ) ; } setAttributes ( attrMap ) ; } if ( store ) { store ( ) ; } }
assigns a set of services and the attributes for a service to the user .
