/*
 *  Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.wso2.carbon.apimgt.persistence;

public class PersistenceManager {
  //  String userName;
  //  Organization org;
    private static APIPersistence apiPersistenceInstance;

    public static APIPersistence getPersistenceInstance(String userName) {
        //condition to check the configured Persistence type
        // if (Persistence type is Registry)
//        if (apiPersistenceInstance == null) {
//            synchronized (RegistryPersistenceImplOld.class) {
//                if (apiPersistenceInstance == null) {
//                    apiPersistenceInstance = new RegistryPersistenceImplOld(userName);
//                }
//            }
//        }
        /*//else if (Persistence type is MongoDb)
        else if (apiPersistenceInstance == null) {
            synchronized (RegistryPersistenceImpl.class) {
                if (apiPersistenceInstance == null) {
                    apiPersistenceInstance = new MongoDBPersistenceImpl(userName);
                }
            }
        }*/
            synchronized (RegistryPersistenceImpl.class) {
                if (apiPersistenceInstance == null) {
                    apiPersistenceInstance = new MongoDBPersistenceImpl(userName);
                }
            }
        return new RegistryPersistenceImpl(userName);
//        return apiPersistenceInstance;
    }

//    public static APIPersistence getInstance(String username) throws APIManagementException {
//        if (apiPersistenceInstance == null) {
//            synchronized (RegistryPersistenceManager.class) {
//                if (apiPersistenceInstance == null) {
//                    apiPersistenceInstance = new RegistryPersistenceManager(username);
//                }
//            }
//        }
//        return apiPersistenceInstance;
//    }
}

@@ -1873,32 +1873,34 @@
 %7D%0A            %7D%0A
+//
         return n
@@ -1929,34 +1929,32 @@
 Impl(userName);%0A
-//
         return a

add mongodb persistent manager