public void registerService(String serviceName,boolean createTemplate,boolean activate) throws AMException, SSOException {
  if (debug.messageEnabled()) {
    debug.message("AMOrganizationalUnitImpl.registerService(" + serviceName + ", "+ createTemplate+ ", "+ activate+ ")");
  }
  dsServices.registerService(super.token,super.entryDN,serviceName);
  Set serviceStatus=getAttribute(SERVICE_STATUS_ATTRIBUTE);
  if (!serviceStatus.equals(Collections.EMPTY_SET)) {
    Iterator iter=serviceStatus.iterator();
    while (iter.hasNext()) {
      String status=(String)iter.next();
      if (status.equalsIgnoreCase(serviceName)) {
        Object args[]={serviceName};
        throw new AMException(AMSDKBundle.getString("464",args,super.locale),"464",args);
      }
    }
  }
 else {
    serviceStatus=new HashSet();
  }
  serviceStatus.add(serviceName);
  setAttribute(SERVICE_STATUS_ATTRIBUTE,serviceStatus);
  try {
    store();
  }
 catch (  AMException le) {
    try {
      Set objectClass=getAttribute("objectclass");
      if (debug.messageEnabled()) {
        debug.message("object class=" + objectClass);
      }
      if (!objectClass.contains("iplanet-am-managed-org-unit")) {
        objectClass.add("iplanet-am-managed-org-unit");
        setAttribute("objectclass",objectClass);
        setAttribute(SERVICE_STATUS_ATTRIBUTE,serviceStatus);
        store();
      }
 else {
        throw le;
      }
    }
 catch (    Exception e) {
      if (debug.messageEnabled()) {
        debug.message("error adding objectclass",e);
      }
      throw le;
    }
  }
  if (createTemplate) {
    try {
      if (AMServiceUtils.serviceHasSubSchema(super.token,serviceName,SchemaType.POLICY)) {
        createTemplate(AMTemplate.POLICY_TEMPLATE,serviceName,null);
      }
      if (AMServiceUtils.serviceHasSubSchema(super.token,serviceName,SchemaType.DYNAMIC)) {
        createTemplate(AMTemplate.DYNAMIC_TEMPLATE,serviceName,null);
      }
    }
 catch (    SMSException smsex) {
      throw new AMException(AMSDKBundle.getString("451",super.locale),"451");
    }
  }
}

public void registerService ( String serviceName , boolean createTemplate , boolean activate ) throws AMException , SSOException { if ( debug . messageEnabled ( ) ) { debug . message ( "AMOrganizationalUnitImpl.registerService(" + serviceName + ", " + createTemplate + ", " + activate + ")" ) ; } dsServices . registerService ( super . token , super . entryDN , serviceName ) ; Set serviceStatus = getAttribute ( SERVICE_STATUS_ATTRIBUTE ) ; if ( ! serviceStatus . equals ( Collections . EMPTY_SET ) ) { Iterator iter = serviceStatus . iterator ( ) ; while ( iter . hasNext ( ) ) { String status = ( String ) iter . next ( ) ; if ( status . equalsIgnoreCase ( serviceName ) ) { Object args [ ] = { serviceName } ; throw new AMException ( AMSDKBundle . getString ( "464" , args , super . locale ) , "464" , args ) ; } } } else { serviceStatus = new HashSet ( ) ; } serviceStatus . add ( serviceName ) ; setAttribute ( SERVICE_STATUS_ATTRIBUTE , serviceStatus ) ; try { store ( ) ; } catch ( AMException le ) { try { Set objectClass = getAttribute ( "objectclass" ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "object class=" + objectClass ) ; } if ( ! objectClass . contains ( "iplanet-am-managed-org-unit" ) ) { objectClass . add ( "iplanet-am-managed-org-unit" ) ; setAttribute ( "objectclass" , objectClass ) ; setAttribute ( SERVICE_STATUS_ATTRIBUTE , serviceStatus ) ; store ( ) ; } else { throw le ; } } catch ( Exception e ) { if ( debug . messageEnabled ( ) ) { debug . message ( "error adding objectclass" , e ) ; } throw le ; } } if ( createTemplate ) { try { if ( AMServiceUtils . serviceHasSubSchema ( super . token , serviceName , SchemaType . POLICY ) ) { createTemplate ( AMTemplate . POLICY_TEMPLATE , serviceName , null ) ; } if ( AMServiceUtils . serviceHasSubSchema ( super . token , serviceName , SchemaType . DYNAMIC ) ) { createTemplate ( AMTemplate . DYNAMIC_TEMPLATE , serviceName , null ) ; } } catch ( SMSException smsex ) { throw new AMException ( AMSDKBundle . getString ( "451" , super . locale ) , "451" ) ; } } }
register a service for this organizational unit .
