Java Code Examples for org.wso2.carbon.registry.core.Collection#getChildren()

The following examples show how to use org.wso2.carbon.registry.core.Collection#getChildren() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistryDataManager.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 *  Obtain the STS policy paths from registry
 *
 * @param registry
 * @return
 * @throws RegistryException
 */
private List<String> getSTSPolicyPaths(Registry registry) throws RegistryException {
    List<String> policyPaths = new ArrayList<>();
    if (registry.resourceExists(Constant.SERVICE_GROUPS_PATH)) {
        Collection serviceGroups = (Collection) registry.get(Constant.SERVICE_GROUPS_PATH);
        if (serviceGroups != null) {
            for (String serviceGroupPath : serviceGroups.getChildren()) {
                if (StringUtils.isNotEmpty(serviceGroupPath) &&
                        serviceGroupPath.contains(Constant.STS_SERVICE_GROUP)) {
                    String policyCollectionPath = new StringBuilder().append(serviceGroupPath)
                            .append(Constant.SECURITY_POLICY_RESOURCE_PATH).toString();
                    Collection policies = (Collection) registry.get(policyCollectionPath);
                    if (policies != null) {
                        policyPaths.addAll(Arrays.asList(policies.getChildren()));
                    }
                }
            }
        }
    }
    return policyPaths;
}
 
Example 2
Source File: UserRealmProxy.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode,
                                              Registry registry, Registry tenantRegistry) throws RegistryException,
        UserStoreException {

    String[] children = parent.getChildren();
    UIPermissionNode[] childNodes = new UIPermissionNode[children.length];
    for (int i = 0; i < children.length; i++) {
        String child = children[i];
        Resource resource = null;

        if (registry.resourceExists(child)) {
            resource = registry.get(child);
        } else if (tenantRegistry != null) {
            resource = tenantRegistry.get(child);
        } else {
            throw new RegistryException("Permission resource not found in the registry.");
        }

        childNodes[i] = getUIPermissionNode(resource, true);
        if (resource instanceof Collection) {
            buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry,
                    tenantRegistry);
        }
    }
    parentNode.setNodeList(childNodes);
}
 
Example 3
Source File: RegistryRecoveryDataStore.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private void deleteOldResourcesIfFound(Registry registry, String userName, String secretKeyPath) {
    try {
        if (registry.resourceExists(secretKeyPath.toLowerCase())) {
            Collection collection = (Collection) registry.get(secretKeyPath.toLowerCase());
            String[] resources = collection.getChildren();
            for (String resource : resources) {
                String[] splittedResource = resource.split("___");
                if (splittedResource.length == 3) {
                    //PRIMARY USER STORE
                    if (resource.contains("___" + userName + "___")) {
                        registry.delete(resource);
                    }
                } else if (splittedResource.length == 2) {
                    //SECONDARY USER STORE. Resource is a collection.
                    deleteOldResourcesIfFound(registry, userName, resource);
                }
            }
        }
    } catch (RegistryException e) {
        log.error("Error while deleting the old confirmation code \n" + e);
    }

}
 
Example 4
Source File: CarbonEntitlementDataFinder.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * This helps to find resources un a recursive manner
 *
 * @param node           attribute value node
 * @param parentResource parent resource Name
 * @return child resource set
 * @throws RegistryException throws
 */
private EntitlementTreeNodeDTO getChildResources(EntitlementTreeNodeDTO node,
                                                 String parentResource) throws RegistryException {

    if (registry.resourceExists(parentResource)) {
        String[] resourcePath = parentResource.split("/");
        EntitlementTreeNodeDTO childNode =
                new EntitlementTreeNodeDTO(resourcePath[resourcePath.length - 1]);
        node.addChildNode(childNode);
        Resource root = registry.get(parentResource);
        if (root instanceof Collection) {
            Collection collection = (Collection) root;
            String[] resources = collection.getChildren();
            for (String resource : resources) {
                getChildResources(childNode, resource);
            }
        }
    }
    return node;
}
 
Example 5
Source File: DefaultResourceFinder.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
@Override
public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
    Set<String> resourceSet = new HashSet<String>();
    registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
            getThreadLocalCarbonContext().getTenantId());
    if (registry.resourceExists(parentResourceId)) {
        Resource resource = registry.get(parentResourceId);
        if (resource instanceof Collection) {
            Collection collection = (Collection) resource;
            String[] resources = collection.getChildren();
            for (String res : resources) {
                resourceSet.add(res);
                getChildResources(res, resourceSet);
            }
        } else {
            return null;
        }
    }
    return resourceSet;
}
 
Example 6
Source File: AbstractAPIManager.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
public Set<String> getAPIVersions(String providerName, String apiName)
        throws APIManagementException {

    Set<String> versionSet = new HashSet<String>();
    String apiPath = APIConstants.API_LOCATION + RegistryConstants.PATH_SEPARATOR +
            providerName + RegistryConstants.PATH_SEPARATOR + apiName;
    try {
        Resource resource = registry.get(apiPath);
        if (resource instanceof Collection) {
            Collection collection = (Collection) resource;
            String[] versionPaths = collection.getChildren();
            if (versionPaths == null || versionPaths.length == 0) {
                return versionSet;
            }
            for (String path : versionPaths) {
                versionSet.add(path.substring(apiPath.length() + 1));
            }
        } else {
            throw new APIManagementException("API version must be a collection " + apiName);
        }
    } catch (RegistryException e) {
        String msg = "Failed to get versions for API: " + apiName;
        throw new APIManagementException(msg, e);
    }
    return versionSet;
}
 
Example 7
Source File: UserRealmProxy.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode,
                                              Registry registry, Registry tenantRegistry) throws RegistryException,
        UserStoreException {

    String[] children = parent.getChildren();
    UIPermissionNode[] childNodes = new UIPermissionNode[children.length];
    for (int i = 0; i < children.length; i++) {
        String child = children[i];
        Resource resource = null;

        if (registry.resourceExists(child)) {
            resource = registry.get(child);
        } else if (tenantRegistry != null) {
            resource = tenantRegistry.get(child);
        } else {
            throw new RegistryException("Permission resource not found in the registry.");
        }

        childNodes[i] = getUIPermissionNode(resource, true);
        if (resource instanceof Collection) {
            buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry,
                    tenantRegistry);
        }
    }
    parentNode.setNodeList(childNodes);
}
 
Example 8
Source File: SAMLSSOServiceProviderDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * This helps to find resources in a recursive manner.
 *
 * @param parentResource      parent resource Name.
 * @param serviceProviderList child resource list.
 * @throws RegistryException
 */
private void getChildResources(String parentResource, List<SAMLSSOServiceProviderDO>
        serviceProviderList) throws RegistryException {

    if (registry.resourceExists(parentResource)) {
        Resource resource = registry.get(parentResource);
        if (resource instanceof Collection) {
            Collection collection = (Collection) resource;
            String[] resources = collection.getChildren();
            for (String res : resources) {
                getChildResources(res, serviceProviderList);
            }
        } else {
            serviceProviderList.add(resourceToObject(resource));
        }
    }
}
 
Example 9
Source File: SAMLSSOServiceProviderDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public SAMLSSOServiceProviderDO[] getServiceProviders() throws IdentityException {
    List<SAMLSSOServiceProviderDO> serviceProvidersList = new ArrayList<>();
    try {
        if (registry.resourceExists(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)) {
            Resource samlSSOServiceProvidersResource = registry.get(IdentityRegistryResources
                    .SAML_SSO_SERVICE_PROVIDERS);
            if (samlSSOServiceProvidersResource instanceof Collection) {
                Collection samlSSOServiceProvidersCollection = (Collection) samlSSOServiceProvidersResource;
                String[] resources = samlSSOServiceProvidersCollection.getChildren();
                for (String resource : resources) {
                    getChildResources(resource, serviceProvidersList);
                }
            }
        }
    } catch (RegistryException e) {
        log.error("Error reading Service Providers from Registry", e);
        throw IdentityException.error("Error reading Service Providers from Registry", e);
    }
    return serviceProvidersList.toArray(new SAMLSSOServiceProviderDO[serviceProvidersList.size()]);
}
 
Example 10
Source File: CarbonEntitlementDataFinder.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * This helps to find resources un a recursive manner
 *
 * @param node           attribute value node
 * @param parentResource parent resource Name
 * @return child resource set
 * @throws RegistryException throws
 */
private EntitlementTreeNodeDTO getChildResources(EntitlementTreeNodeDTO node,
                                                 String parentResource) throws RegistryException {

    if (registry.resourceExists(parentResource)) {
        String[] resourcePath = parentResource.split("/");
        EntitlementTreeNodeDTO childNode =
                new EntitlementTreeNodeDTO(resourcePath[resourcePath.length - 1]);
        node.addChildNode(childNode);
        Resource root = registry.get(parentResource);
        if (root instanceof Collection) {
            Collection collection = (Collection) root;
            String[] resources = collection.getChildren();
            for (String resource : resources) {
                getChildResources(childNode, resource);
            }
        }
    }
    return node;
}
 
Example 11
Source File: ChallengeQuestionProcessor.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * @return
 * @throws IdentityException
 */
public List<ChallengeQuestionDTO> getAllChallengeQuestions() throws IdentityException {

    List<ChallengeQuestionDTO> questionDTOs = new ArrayList<ChallengeQuestionDTO>();
    try {
        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        Registry registry = IdentityMgtServiceComponent.getRegistryService().
                getConfigSystemRegistry(tenantId);
        if (registry.resourceExists(IdentityMgtConstants.IDENTITY_MANAGEMENT_QUESTIONS)) {
            Collection collection = (Collection) registry.
                    get(IdentityMgtConstants.IDENTITY_MANAGEMENT_QUESTIONS);
            String[] children = collection.getChildren();
            for (String child : children) {
                Resource resource = registry.get(child);
                String question = resource.getProperty("question");
                String isPromoteQuestion = resource.getProperty("isPromoteQuestion");
                String questionSetId = resource.getProperty("questionSetId");
                if (question != null) {
                    ChallengeQuestionDTO questionDTO = new ChallengeQuestionDTO();
                    questionDTO.setQuestion(question);
                    if (isPromoteQuestion != null) {
                        questionDTO.setPromoteQuestion(Boolean.parseBoolean(isPromoteQuestion));
                    }
                    if (questionSetId != null) {
                        questionDTO.setQuestionSetId(questionSetId);
                    }
                    questionDTO.setPromoteQuestion(false);
                    questionDTOs.add(questionDTO);
                }
            }

        }
    } catch (RegistryException e) {
        throw IdentityException.error(e.getMessage(), e);
    }
    return questionDTOs;
}
 
Example 12
Source File: RegistryDataManager.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Migrate keystore password in super tenant and other tenants
 *
 * @param tenantId
 * @throws RegistryException
 * @throws CryptoException
 */
private void migrateKeyStorePasswordForTenant(int tenantId) throws RegistryException, CryptoException {
    Registry registry = MigrationServiceDataHolder.getRegistryService().getGovernanceSystemRegistry(tenantId);
    if (registry.resourceExists(Constant.KEYSTORE_RESOURCE_PATH)) {
        Collection keyStoreCollection = (Collection) registry.get(Constant.KEYSTORE_RESOURCE_PATH);
        for (String keyStorePath : keyStoreCollection.getChildren()) {
            updateRegistryProperties(registry, keyStorePath,
                    new ArrayList<>(Arrays.asList(Constant.PASSWORD, Constant.PRIVATE_KEY_PASS)));
        }
    }
}
 
Example 13
Source File: AbstractAPIManager.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the mediation policy registry resource correspond to the given identifier
 *
 * @param mediationPolicyId uuid of the mediation resource
 * @return Registry resource of given identifier or null
 * @throws APIManagementException If failed to get the registry resource of given uuid
 */
@Override
public Resource getCustomMediationResourceFromUuid(String mediationPolicyId)
        throws APIManagementException {
    String resourcePath = APIConstants.API_CUSTOM_SEQUENCE_LOCATION;
    try {
        Resource resource = registry.get(resourcePath);
        //resource : customsequences
        if (resource instanceof Collection) {
            Collection typeCollection = (Collection) resource;
            String[] typeArray = typeCollection.getChildren();
            for (String type : typeArray) {
                Resource typeResource = registry.get(type);
                //typeResource: in/ out/ fault
                if (typeResource instanceof Collection) {
                    String[] policyArray = ((Collection) typeResource).getChildren();
                    if (policyArray.length > 0) {
                        for (String policy : policyArray) {
                            Resource mediationResource = registry.get(policy);
                            //mediationResource: eg .log_in_msg.xml
                            String resourceId = mediationResource.getUUID();
                            if (resourceId.equals(mediationPolicyId)) {
                                //If registry resource id matches given identifier returns that
                                // registry resource
                                return mediationResource;
                            }
                        }
                    }
                }
            }
        }
    } catch (RegistryException e) {
        String msg = "Error while accessing registry objects";
        throw new APIManagementException(msg, e);
    }
    return null;
}
 
Example 14
Source File: UserRealmProxy.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private void buildUIPermissionNodeNotAllSelected(Collection parent, UIPermissionNode parentNode,
                                                 Registry registry, Registry tenantRegistry,
                                                 AuthorizationManager authMan, String roleName, String userName)
        throws RegistryException, UserStoreException {

    String[] children = parent.getChildren();
    UIPermissionNode[] childNodes = new UIPermissionNode[children.length];

    for (int i = 0; i < children.length; i++) {
        String child = children[i];
        Resource resource = null;

        if (tenantRegistry != null && child.startsWith("/permission/applications")) {
            resource = tenantRegistry.get(child);
        } else if (registry.resourceExists(child)) {
            resource = registry.get(child);
        } else {
            throw new RegistryException("Permission resource not found in the registry.");
        }

        boolean isSelected = false;
        if (roleName != null) {
            isSelected = authMan.isRoleAuthorized(roleName, child,
                    UserMgtConstants.EXECUTE_ACTION);
        } else if (userName != null) {
            isSelected = authMan.isUserAuthorized(userName, child,
                    UserMgtConstants.EXECUTE_ACTION);
        }
        childNodes[i] = getUIPermissionNode(resource, isSelected);
        if (resource instanceof Collection) {
            buildUIPermissionNodeNotAllSelected((Collection) resource, childNodes[i],
                    registry, tenantRegistry, authMan, roleName, userName);
        }
    }
    parentNode.setNodeList(childNodes);
}
 
Example 15
Source File: RegistryManager.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public MappingData[] getTenantSpecificMappingsFromRegistry(String tenantDomain) throws Exception {
  	
  	Collection mappings = getHostsFromRegistry();
List<MappingData> mappingList = new ArrayList<MappingData>();
if (mappings != null) {
	String[] mappingNames = mappings.getChildren();
	for (String mappingName : mappingNames) {
		mappingName = mappingName.replace(UrlMapperConstants.HostProperties.FILE_SERPERATOR
          	        + UrlMapperConstants.HostProperties.HOSTINFO , "");
		Resource resource = getMappingFromRegistry(mappingName);
		if (resource != null) {
			MappingData mappingData = new MappingData();
			mappingData.setMappingName(resource
					.getProperty(UrlMapperConstants.HostProperties.HOST_NAME));
			mappingData.setTenantDomain(resource
					.getProperty(UrlMapperConstants.HostProperties.TENANT_DOMAIN));
			if (resource.getProperty(UrlMapperConstants.HostProperties.SERVICE_EPR) != null) {
				mappingData.setServiceMapping(true);
				mappingData.setUrl(resource
						.getProperty(UrlMapperConstants.HostProperties.SERVICE_EPR));
			} else {
				mappingData.setUrl(resource
						.getProperty(UrlMapperConstants.HostProperties.WEB_APP));
			}
			if (tenantDomain == null || tenantDomain.equals("")) {
				mappingList.add(mappingData);
			} else if (tenantDomain.equals(mappingData.getTenantDomain())) {
				mappingList.add(mappingData);
			}
			
		}

	}
	return mappingList.toArray(new MappingData[mappingList.size()]);
}
return null;
  }
 
Example 16
Source File: PolicyPublisher.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public String[] retrieveSubscriberIds(String searchString) throws EntitlementException {

        try {
            if (registry.resourceExists(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER +
                    RegistryConstants.PATH_SEPARATOR)) {
                Resource resource = registry.get(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER +
                        RegistryConstants.PATH_SEPARATOR);
                Collection collection = (Collection) resource;
                List<String> list = new ArrayList<String>();
                if (collection.getChildCount() > 0) {
                    searchString = searchString.replace("*", ".*");
                    Pattern pattern = Pattern.compile(searchString, Pattern.CASE_INSENSITIVE);
                    for (String path : collection.getChildren()) {
                        String id = path.substring(path.lastIndexOf(RegistryConstants.PATH_SEPARATOR) + 1);
                        Matcher matcher = pattern.matcher(id);
                        if (!matcher.matches()) {
                            continue;
                        }
                        Resource childResource = registry.get(path);
                        if (childResource != null && childResource.getProperty(SUBSCRIBER_ID) != null) {
                            list.add(childResource.getProperty(SUBSCRIBER_ID));
                        }
                    }
                }
                return list.toArray(new String[list.size()]);
            }
        } catch (RegistryException e) {
            log.error("Error while retrieving subscriber of ids", e);
            throw new EntitlementException("Error while retrieving subscriber ids", e);

        }

        return null;
    }
 
Example 17
Source File: DefaultPolicyDataStore.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public PolicyStoreDTO[] getPolicyData() {

    Registry registry = EntitlementServiceComponent.
            getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
    List<PolicyStoreDTO> policyStoreDTOs = new ArrayList<PolicyStoreDTO>();
    try {
        if (registry.resourceExists(policyDataCollection)) {
            Collection collection = (Collection) registry.get(policyDataCollection);
            String[] paths = collection.getChildren();
            for (String path : paths) {
                if (registry.resourceExists(path)) {
                    PolicyStoreDTO dataDTO = new PolicyStoreDTO();
                    Resource resource = registry.get(path);
                    String order = resource.getProperty("order");
                    String active = resource.getProperty("active");
                    String id = path.substring(path.lastIndexOf(RegistryConstants.PATH_SEPARATOR) + 1);
                    dataDTO.setPolicyId(id);
                    if (order != null && order.trim().length() > 0) {
                        dataDTO.setPolicyOrder(Integer.parseInt(order));
                    }
                    dataDTO.setActive(Boolean.parseBoolean(active));
                    policyStoreDTOs.add(dataDTO);
                }
            }
        }
    } catch (RegistryException e) {
        if (log.isDebugEnabled()) {
            log.debug(e);
        }
    }
    return policyStoreDTOs.toArray(new PolicyStoreDTO[policyStoreDTOs.size()]);
}
 
Example 18
Source File: RegistryBasedTrustedServiceStore.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Get all trusted services
 *
 * @return
 * @throws Exception
 */
public ClaimDTO[] getAllTrustedServices() throws Exception {
    try {
        Registry registry = IdentityPassiveSTSServiceComponent.getConfigSystemRegistry();
        List<ClaimDTO> trustedServices = new ArrayList<ClaimDTO>();

        if (!registry.resourceExists(registryTrustedServicePath)) {
            return new ClaimDTO[0];
        }
        Collection trustedServiceCollection = (Collection) registry.get(registryTrustedServicePath);
        for (String resourcePath : trustedServiceCollection.getChildren()) {
            Resource resource = registry.get(resourcePath);
            ClaimDTO claimDTO = new ClaimDTO();
            claimDTO.setRealm(resource.getProperty(REALM_NAME).replace(SLASH_REPLACE_CHARACTER, "/"));

            String claims = resource.getProperty(CLAIMS);
            if (claims.startsWith("[")) {
                claims = claims.replaceFirst("\\[", "");
            }
            if (claims.endsWith("]")) {
                claims = claims.substring(0, claims.length() - 2);
            }
            claimDTO.setDefaultClaims(claims.split(","));

            claimDTO.setClaimDialect(resource.getProperty(CLAIM_DIALECT));

            trustedServices.add(claimDTO);
        }

        return trustedServices.toArray(new ClaimDTO[trustedServices.size()]);
    } catch (RegistryException e) {
        String error = "Error occurred when getting all trusted services due to error in accessing registry.";
        throw new Exception(error, e);
    }
}
 
Example 19
Source File: AbstractAPIManager.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Returns Registry resource matching given mediation policy identifier
 *
 * @param identifier API identifier
 * @param uuid         mediation policy identifier
 * @param resourcePath registry path to the API resource
 * @return Registry resource matches given identifier or null
 * @throws APIManagementException If fails to get the resource matching given identifier
 */
@Override
public Resource getApiSpecificMediationResourceFromUuid(Identifier identifier, String uuid, String resourcePath)
        throws APIManagementException {
    try {
        Resource resource = registry.get(resourcePath);
        if (resource instanceof Collection) {
            Collection typeCollection = (Collection) resource;
            String[] typeArray = typeCollection.getChildren();
            for (String type : typeArray) {
                //Check for mediation policy resource
                if ((type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR +
                        APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN)) ||
                        (type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR +
                                APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT)) ||
                        (type.equalsIgnoreCase(resourcePath + RegistryConstants.PATH_SEPARATOR +
                                APIConstants.API_CUSTOM_SEQUENCE_TYPE_FAULT))) {
                    Resource sequenceType = registry.get(type);
                    //sequenceType eg: in / out /fault
                    if (sequenceType instanceof Collection) {
                        String[] mediationPolicyArr = ((Collection) sequenceType).getChildren();
                        for (String mediationPolicy : mediationPolicyArr) {
                            Resource mediationResource = registry.get(mediationPolicy);
                            String resourceId = mediationResource.getUUID();
                            if (resourceId.equalsIgnoreCase(uuid)) {
                                return mediationResource;
                            }
                        }
                    }
                }
            }
        }
    } catch (RegistryException e) {
        String msg = "Error while obtaining registry objects";
        throw new APIManagementException(msg, e);
    }
    return null;
}
 
Example 20
Source File: ProviderMigrationClient.java    From product-es with Apache License 2.0 4 votes vote down vote up
private void migrate(Tenant tenant)
        throws UserStoreException, RegistryException, SAXException, TransformerException,
               ParserConfigurationException, IOException, XMLStreamException {
    int tenantId = tenant.getId();
    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenant.getDomain(), true);
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
        String adminName = ServiceHolder.getRealmService().getTenantUserRealm(tenantId).getRealmConfiguration()
                .getAdminUserName();
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(adminName);
        ServiceHolder.getTenantRegLoader().loadTenantRegistry(tenantId);
        Registry registry = ServiceHolder.getRegistryService().getRegistry(adminName, tenantId);
        Collection resourceTypes = (Collection) registry.get(Constants.RESOURCETYPES_RXT_PATH);
        String[] resourceTypesRxtPaths = resourceTypes.getChildren();
        for (String resourceTypeRxtPath : resourceTypesRxtPaths) {
            if (!isContentArtifact(resourceTypeRxtPath, registry)) {
                ServiceHolder.getRXTStoragePathService().addStoragePath(getMediaType(resourceTypeRxtPath, registry),
                                                                        getStoragePath(resourceTypeRxtPath, registry));
                if (!(getStoragePath(resourceTypeRxtPath, registry).contains("@{overview_provider}")) ||
                    !hasOverviewProviderElement(resourceTypeRxtPath, registry)) {
                    String[] storagePathElements = getStoragePath(resourceTypeRxtPath, registry).split("/");
                    String storagePath = Constants.GOV_PATH;
                    for (String storagePathElement : storagePathElements) {
                        if (storagePathElement.startsWith("@")) {
                            break;
                        }
                        if (!storagePathElement.isEmpty()) {
                            storagePath += ("/" + storagePathElement);
                        }
                    }
                    if (registry.resourceExists(storagePath)) {
                        Collection storageCollection = (Collection) registry.get(storagePath);
                        migrateProvider(storageCollection, registry);
                    }
                }


            }
        }
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}