Beispiel #1
0
 /**
  * Removes the service schema and configuration for the given service name.
  *
  * @param serviceName the name of the service
  * @param version the version of the service
  * @throws SMSException if an error occurred while performing the operation
  * @throws SSOException if the user's single sign on token is invalid or expired
  * @supported.api
  */
 public void removeService(String serviceName, String version) throws SMSException, SSOException {
   // Find all service entries that have the DN
   // Search for (&(ou=<serviceName>)(objectclass=top))
   // construct the rdn with the given version, look for the entry
   // in iDS and if entry exists(service with that version), delete.
   if (serviceName.equalsIgnoreCase(IdConstants.REPO_SERVICE)
       || serviceName.equalsIgnoreCase(ISAuthConstants.AUTH_SERVICE_NAME)) {
     Object args[] = {serviceName};
     throw (new SMSException(
         IUMSConstants.UMS_BUNDLE_NAME, "sms-SERVICE_CORE_CANNOT_DELETE", args));
   }
   SMSEntry.validateToken(token);
   String[] objs = {serviceName};
   Iterator results =
       SMSEntry.search(
               token,
               SMSEntry.baseDN,
               MessageFormat.format(SMSEntry.FILTER_PATTERN, (Object[]) objs),
               0,
               0,
               false,
               false)
           .iterator();
   while (results.hasNext()) {
     String dn = (String) results.next();
     String configdn = SMSEntry.PLACEHOLDER_RDN + SMSEntry.EQUALS + version + SMSEntry.COMMA + dn;
     CachedSMSEntry configsmse = CachedSMSEntry.getInstance(token, configdn);
     if (configsmse.isDirty()) {
       configsmse.refresh();
     }
     SMSEntry confige = configsmse.getClonedSMSEntry();
     if (!confige.isNewEntry()) {
       confige.delete(token);
       configsmse.refresh(confige);
     }
     // If there are no other service version nodes for that service,
     // delete that node(schema).
     CachedSMSEntry smse = CachedSMSEntry.getInstance(token, dn);
     if (smse.isDirty()) {
       smse.refresh();
     }
     SMSEntry e = smse.getSMSEntry();
     Iterator versions = e.subEntries(token, "*", 0, false, false).iterator();
     if (!versions.hasNext()) {
       e.delete(token);
       smse.refresh(e);
     }
   }
 }