// Path: components/governance/org.wso2.carbon.governance.taxonomy/src/main/java/org/wso2/carbon/governance/taxonomy/util/CommonUtils.java
// public static OMElement buildOMElement(String payload) throws RegistryException {
//     OMElement element;
//     try {
//         element = AXIOMUtil.stringToOM(payload);
//         element.build();
//     } catch (Exception e) {
//         String message = "Unable to parse the XML configuration. Please validate the XML configuration";
//         throw new RegistryException(message, e);
//     }
//     return element;
// }


import static org.wso2.carbon.governance.taxonomy.util.TaxonomyConstants.TAXONOMY_CONFIGURATION_PATH;
import static org.wso2.carbon.governance.taxonomy.util.TaxonomyConstants.TAXONOMY_MEDIA_TYPE;
import org.apache.axiom.om.OMElement;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.taxonomy.beans.TaxonomyBean;
import org.wso2.carbon.governance.taxonomy.clustering.ClusterMessage;
import org.wso2.carbon.governance.taxonomy.clustering.ClusteringUtil;
import org.wso2.carbon.governance.taxonomy.exception.TaxonomyException;
import org.wso2.carbon.registry.common.services.RegistryAbstractAdmin;
import org.wso2.carbon.registry.core.*;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.utils.RegistryUtils;
import javax.xml.namespace.QName;
import static org.wso2.carbon.governance.taxonomy.util.CommonUtils.buildOMElement;
/*
 * Copyright (c) 2016, 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.governance.taxonomy.services;




class ManagementProviderImpl extends RegistryAbstractAdmin implements IManagementProvider {

    /**
     * This method will add user defined taxonomy content into the registry
     *
     * @param storageProvider storage provider instance
     * @param taxonomyBean    taxonomy bean instance which contains taxonomy meta data
     * @return
     * @throws RegistryException
     */
    @Override
    public boolean addTaxonomy(IStorageProvider storageProvider, TaxonomyBean taxonomyBean)
            throws RegistryException {
        Registry registry = getGovernanceUserRegistry();
        Resource resource;
        String name;
        OMElement element = null;
// Path: components/governance/org.wso2.carbon.governance.taxonomy/src/main/java/org/wso2/carbon/governance/taxonomy/util/CommonUtils.java
// public static OMElement buildOMElement(String payload) throws RegistryException {
//     OMElement element;
//     try {
//         element = AXIOMUtil.stringToOM(payload);
//         element.build();
//     } catch (Exception e) {
//         String message = "Unable to parse the XML configuration. Please validate the XML configuration";
//         throw new RegistryException(message, e);
//     }
//     return element;
// }


// Path: components/governance/org.wso2.carbon.governance.taxonomy/src/main/java/org/wso2/carbon/governance/taxonomy/services/ManagementProviderImpl.java
import static org.wso2.carbon.governance.taxonomy.util.TaxonomyConstants.TAXONOMY_CONFIGURATION_PATH;
import static org.wso2.carbon.governance.taxonomy.util.TaxonomyConstants.TAXONOMY_MEDIA_TYPE;
import org.apache.axiom.om.OMElement;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.governance.taxonomy.beans.TaxonomyBean;
import org.wso2.carbon.governance.taxonomy.clustering.ClusterMessage;
import org.wso2.carbon.governance.taxonomy.clustering.ClusteringUtil;
import org.wso2.carbon.governance.taxonomy.exception.TaxonomyException;
import org.wso2.carbon.registry.common.services.RegistryAbstractAdmin;
import org.wso2.carbon.registry.core.*;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.utils.RegistryUtils;
import javax.xml.namespace.QName;
import static org.wso2.carbon.governance.taxonomy.util.CommonUtils.buildOMElement;

/*
 * Copyright (c) 2016, 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.governance.taxonomy.services;




class ManagementProviderImpl extends RegistryAbstractAdmin implements IManagementProvider {

    /**
     * This method will add user defined taxonomy content into the registry
     *
     * @param storageProvider storage provider instance
     * @param taxonomyBean    taxonomy bean instance which contains taxonomy meta data
     * @return
     * @throws RegistryException
     */
    @Override
    public boolean addTaxonomy(IStorageProvider storageProvider, TaxonomyBean taxonomyBean)
            throws RegistryException {
        Registry registry = getGovernanceUserRegistry();
        Resource resource;
        String name;
        OMElement element = null;
        element = buildOMElement(taxonomyBean.getPayload());