AafServiceFactory implementation
[dmaap/dbcapi.git] / src / main / java / org / onap / dmaap / dbcapi / service / TopicService.java
index 3386b97..c432254 100644 (file)
@@ -23,7 +23,7 @@
 package org.onap.dmaap.dbcapi.service;
 
 import org.onap.dmaap.dbcapi.aaf.AafService.ServiceType;
-import org.onap.dmaap.dbcapi.aaf.AafServiceImpl;
+import org.onap.dmaap.dbcapi.aaf.AafServiceFactory;
 import org.onap.dmaap.dbcapi.database.DatabaseClass;
 import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
 import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
@@ -71,7 +71,7 @@ public class TopicService extends BaseLoggingClass {
         this(DatabaseClass.getTopics(), new MR_ClientService(), (DmaapConfig) DmaapConfig.getConfig(),
                 new MR_ClusterService(), new DcaeLocationService(), new MirrorMakerService(),
                 new AafTopicSetupService(
-                        new AafServiceImpl(ServiceType.AAF_TopicMgr),
+                        new AafServiceFactory().initAafService(ServiceType.AAF_TopicMgr),
                         dmaapSvc,
                         "true".equalsIgnoreCase(DmaapConfig.getConfig().getProperty("aaf.CreateTopicRoles", "true"))));
 
@@ -246,11 +246,16 @@ public class TopicService extends BaseLoggingClass {
             apiError.setFields("fqtn");
             return null;
         }
+
+        ApiError topicSetupError = aafTopicSetupService.aafTopicCleanup(topic);
+        updateApiError(apiError, topicSetupError);
+        if (apiError.getCode() >= 400) {
+            return null;
+        }
+
         ArrayList<MR_Client> clients = new ArrayList<MR_Client>(clientService.getAllMrClients(pubId));
         for (Iterator<MR_Client> it = clients.iterator(); it.hasNext(); ) {
             MR_Client c = it.next();
-
-
             clientService.removeMr_Client(c.getMrClientId(), false, apiError);
             if (!apiError.is2xx()) {
                 return null;