Package org.wso2.carbon.registry.core.config

Examples of org.wso2.carbon.registry.core.config.RegistryContext


     * @param cachePath      cached resource path
     * @param recursive      whether this operation must be recursively applied on child resources
     */
    private void clearCache(RequestContext requestContext, String cachePath, boolean recursive) {
        String connectionId = "";
        RegistryContext registryContext = requestContext.getRegistryContext();
        if (registryContext == null) {
            registryContext = RegistryContext.getBaseInstance();
        }
        DataBaseConfiguration dataBaseConfiguration =
                registryContext.getDefaultDataBaseConfiguration();
        if (dataBaseConfiguration != null) {
            connectionId = dataBaseConfiguration.getUserName() + "@" +
                    dataBaseConfiguration.getDbUrl();
        }
        RegistryCacheKey registryCacheKey =
View Full Code Here


    // Initializes the user registry.
    private void init(
            String userName, int tenantId, Registry registry,
            RealmService realmService, String chroot) throws RegistryException {

        RegistryContext registryContext = registry.getRegistryContext();

        if (registryContext.isCacheEnabled() && registry instanceof EmbeddedRegistry) {
            this.coreRegistry = new CacheBackedRegistry(registry);
        } else {
            this.coreRegistry = registry;
        }
        this.isAPPRemoteRegistry = registry instanceof RemoteRegistry;
        this.chrootWrapper = new ChrootWrapper(chroot);
        this.callerTenantId = tenantId;
        this.tenantId = tenantId;
        this.realmService = realmService;

        // TODO : This code needs some careful thought, and fixing.
        this.userName = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
        if (realmService != null) {
            try {
                this.userRealm = new RegistryRealm(realmService.getBootstrapRealm());
            } catch (Exception e) {
                String msg = "Failed in getting the bootstrap realm for the tenantId: " + tenantId
                        + ".";
                log.error(msg);
                throw new RegistryException(msg, e);
            }
        }
       
        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            try {
                UserRealm realm = null;
                if (realmService != null) {
                    realm = (UserRealm) realmService.getTenantUserRealm(tenantId);
                }
                if (realm == null) {
                    String msg = "Failed to obtain the user realm for tenant: " + tenantId + ".";
                    throw new RegistryException(msg);
                }
                this.userRealm = new RegistryRealm(realm);
            } catch (UserStoreException e) {
                String msg = "An error occurred while obtaining the user realm for the tenant: " +
                        tenantId + ".";
                log.error(msg);
                throw new RegistryException(msg, e);
            }
        }
       

        // this is to get a system registry
        try {
            setSessionInformation();
            // The root must be setup, in case the remote registry does not have it.
            if (registryContext.isClone()) {
                try {
                    addRootCollection();
                } catch (Exception ignored) {
                    // There can be situations where the remote instance doesn't like creating the
                    // root collection, if it is already there. Hence, we can simply ignore this.
                }
            } else {
                addRootCollection();
            }
            if (!registryContext.isClone()) {
                addSystemCollections();
            }
        } finally {
            clearSessionInformation();
        }
View Full Code Here

            return;
        }
        if (log.isTraceEnabled()) {
            log.trace("adding system collections.");
        }
        RegistryContext registryContext = coreRegistry.getRegistryContext();

        try {
            setSessionInformation();

            // Adding base collection structure.
            RegistryUtils.addBaseCollectionStructure(coreRegistry, this.userRealm);

            // Adding collection to store user profile information.
            RegistryUtils.addUserProfileCollection(this.coreRegistry, RegistryUtils.getAbsolutePath(
                    registryContext, registryContext.getProfilesPath()));

            // Adding collection to store services.
            RegistryUtils
                    .addServiceStoreCollection(this.coreRegistry, RegistryUtils.getAbsolutePath(
                            registryContext, registryContext.getServicePath()));

            // bootstrap configuration is created
            // RegistryUtils.addDefaultRealmConfiguration(this.coreRegistry, this.userRealm,
            // this.tenantId);
View Full Code Here

    // Creates a queue service for logging events
    private void startLogWriter(RegistryService registryService) throws RegistryException {

        Registry registry = registryService.getRegistry(
                CarbonConstants.REGISTRY_SYSTEM_USERNAME);
        RegistryContext registryContext = registry.getRegistryContext();
        if (bundleContext != null) {
            bundleContext.registerService(LogQueue.class.getName(),
                    registryContext.getLogWriter().getLogQueue(), null);
        }
    }
View Full Code Here


    // Defines the fixed mount points.
    private void defineFixedMount(Registry registry, String path, boolean isSuperTenant)
            throws RegistryException {
        RegistryContext registryContext = registry.getRegistryContext();
        String relativePath = RegistryUtils.getRelativePath(registryContext, path);
        String lookupPath = RegistryUtils.getAbsolutePath(registryContext,
                RegistryConstants.LOCAL_REPOSITORY_BASE_PATH +
                        RegistryConstants.SYSTEM_MOUNT_PATH) + "/" +
                relativePath.replace("/", "-");
View Full Code Here

    }

    // Determines whether a given mount point is a fixed mount or not.
    private boolean isFixedMount(Registry registry, String path, String targetPath,
                                 boolean isSuperTenant) throws RegistryException {
        RegistryContext registryContext = registry.getRegistryContext();
        String relativePath = RegistryUtils.getRelativePath(registryContext, path);
        String lookupPath = RegistryUtils.getAbsolutePath(registryContext,
                RegistryConstants.LOCAL_REPOSITORY_BASE_PATH +
                        RegistryConstants.SYSTEM_MOUNT_PATH) + "/" +
                relativePath.replace("/", "-");
View Full Code Here

            boolean isSuperTenant = (tenantId == MultitenantConstants.SUPER_TENANT_ID);
            Registry superTenantRegistry = registryService.getRegistry(
                    CarbonConstants.REGISTRY_SYSTEM_USERNAME);
            Registry registry = registryService.getRegistry(
                    CarbonConstants.REGISTRY_SYSTEM_USERNAME, tenantId);
            RegistryContext registryContext = superTenantRegistry.getRegistryContext();
            for (Mount mount : registryContext.getMounts()) {
                if (isFixedMount(registry, mount.getPath(), mount.getTargetPath(), isSuperTenant)) {
                    addFixedMount(tenantId, superTenantRegistry, mount.getPath());
                    continue;
                }
                if (!registry.resourceExists(mount.getPath())) {
View Full Code Here

    private void addFixedMount(int tenantId, Registry registry, String path)
            throws RegistryException {
        CurrentSession.setCallerTenantId(tenantId);
        try {
            RegistryContext registryContext = registry.getRegistryContext();
            String relativePath = RegistryUtils.getRelativePath(registryContext, path);
            String lookupPath = RegistryUtils.getAbsolutePath(registryContext,
                    RegistryConstants.LOCAL_REPOSITORY_BASE_PATH +
                            RegistryConstants.SYSTEM_MOUNT_PATH) + "/" +
                    relativePath.replace("/", "-");
View Full Code Here

        if (log.isTraceEnabled()) {
            log.trace("Registering the built-in handlers.");
        }
        Registry registry = registryService.getRegistry(
                CarbonConstants.REGISTRY_SYSTEM_USERNAME);
        RegistryContext registryContext = registry.getRegistryContext();
        HandlerManager handlerManager = registryContext.getHandlerManager();

        if (log.isTraceEnabled()) {
            log.trace("Engaging the Operation Statistics Handler.");
        }
        // handler to record system statistics
View Full Code Here

    // Gets registry service for the Embedded Registry
    private RegistryService getEmbeddedRegistryService() throws Exception {

        InputStream configInputStream = new FileInputStream(getConfigFile());
        RegistryContext registryContext =
                RegistryContext.getBaseInstance(configInputStream, realmService);
        registryContext.setSetup(System.getProperty(RegistryConstants.SETUP_PROPERTY) != null);
        return new EmbeddedRegistryService(registryContext);
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.config.RegistryContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.