Examples of RegistryContext


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

            throw new RegistryException(msg);
        }


        CollectionImpl collection = new CollectionImpl();
        RegistryContext registryContext = null;
        if (CurrentSession.getUserRegistry() != null) {
            registryContext = CurrentSession.getUserRegistry().getRegistryContext();
        }
        if (registryContext == null) {
            registryContext = RegistryContext.getBaseInstance();
        }
        if (!Boolean.FALSE.equals(CurrentSession.getAttribute(IS_LOGGING_ACTIVITY))) {
            registryContext.getLogWriter().addLog(
                    path, CurrentSession.getUser(), LogEntry.ADD, null);
        }
        resourceDAO.add(path, parentResourceID, collection);
    }
View Full Code Here

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

        String domain = userNameWithDomain.substring(atIndex + 1, userNameWithDomain.length());
        return getTenantIdFromDomain(domain);
    }

    private static int getTenantIdFromDomain(String domain) throws RegistryException {
        RegistryContext registryContext = RegistryContext.getBaseInstance();
        RealmService realmService = registryContext.getRealmService();
        if (realmService == null) {
            String msg = "Error in getting the tenant manager. The realm service is not available.";
            log.error(msg);
            throw new RegistryException(msg);
        }
View Full Code Here

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

     * Method to clean the embedded registry instance, after the synchronization operation. This
     * method should only be invoked if the synchronization happens at a client that terminates soon
     * after the execution of the synchronization operation, to prevent loss of activity logs.
     */
    public static void cleanEmbeddedRegistry() {
        RegistryContext registryContext = RegistryContext.getBaseInstance();
        if (registryContext != null) {
            LogWriter logWriter = registryContext.getLogWriter();
            if (logWriter != null) {
                logWriter.interrupt();
            }
        }
    }
View Full Code Here

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

     *
     * @return the cache key.
     */
    public static RegistryCacheKey buildRegistryCacheKey(String connectionId, int tenantId,
                                                   String resourcePath) {
        RegistryContext registryContext = RegistryContext.getBaseInstance();
        String absoluteLocalRepositoryPath = getAbsolutePath(registryContext,
                RegistryConstants.LOCAL_REPOSITORY_BASE_PATH);
        if (resourcePath != null && resourcePath.startsWith(absoluteLocalRepositoryPath)) {
            return new RegistryCacheKey(resourcePath, tenantId,
                    registryContext.getNodeIdentifier() + ":" + connectionId);
        } else {
            return new RegistryCacheKey(resourcePath, tenantId, connectionId);
        }
    }
View Full Code Here

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

     *
     * @throws RegistryException if an error occurred.
     */
    public static boolean systemResourceShouldBeAdded(Registry registry, String absolutePath)
        throws RegistryException {
        RegistryContext registryContext = registry.getRegistryContext();
        if (registryContext == null) {
            registryContext = RegistryContext.getBaseInstance();
        }
        if (registryContext.isSystemResourcePathRegistered(absolutePath)) {
            return false;
        } else if (registry.resourceExists(absolutePath)) {
            registryContext.registerSystemResourcePath(absolutePath);
            return false;
        }
        return true;
    }
View Full Code Here

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

     * @throws RegistryException if an error occurred.
     */
    public static boolean systemResourceShouldBeAdded(ResourceDAO dataAccessObject,
                                                      String absolutePath)
            throws RegistryException {
        RegistryContext registryContext = RegistryContext.getBaseInstance();
        if (RegistryContext.getBaseInstance().isSystemResourcePathRegistered(absolutePath)) {
            return false;
        } else if (dataAccessObject.resourceExists(absolutePath)) {
            registryContext.registerSystemResourcePath(absolutePath);
            return false;
        }
        return true;
    }
View Full Code Here

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

     * @throws RegistryException if the operation failed.
     */
    @Deprecated
    @SuppressWarnings("unused")
    public static UserRealm getBootstrapRealm() throws RegistryException {
        RegistryContext registryContext = RegistryContext.getBaseInstance();
        if (registryContext == null) {
            String msg = "Registry context is null. Failed to get the registry context.";
            log.error(msg);
            throw new RegistryException(msg);
        }
        if (registryContext.getRealmService() == null) {
            String msg = "Error in getting the bootstrap realm. " +
                    "The realm service is not available.";
            log.error(msg);
            throw new RegistryException(msg);
        }
        try {
            UserRealm realm = registryContext.getRealmService().getBootstrapRealm();
            return new RegistryRealm(realm);
        } catch (Exception e) {
            String msg = "Error in getting the user realm for main tenant.";
            log.error(msg);
            throw new RegistryException(msg, e);
View Full Code Here

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

        }
        if (CurrentSession.getUserRealm() != null) {
            // we are already checking the unchrooted paths, so no more work
            return localPath;
        }
        RegistryContext registryContext = RegistryContext.getBaseInstance();
        if (registryContext == null) {
            // adding non-path resources at the start-up
            return localPath;
        }
        String chrootPrefix = registryContext.getRegistryRoot();
        if (chrootPrefix == null ||
                chrootPrefix.length() == 0 ||
                chrootPrefix.equals(RegistryConstants.ROOT_PATH)) {
            return localPath;
        }
View Full Code Here

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

    public void testSimpleLifecycle() throws Exception {
        final String RESOURCE = "/r1";
        final String LIFECYCLE = "simpleLifecycle";

        RegistryContext context = registry.getRegistryContext();
        context.selectDBConfig("h2-db");
        context.addAspect(LIFECYCLE, new SimpleLifecycle(), 0);

        String [] aspects = registry.getAvailableAspects();
        assertTrue(aspects.length > 0);
        boolean found = false;
        for (String aspect : aspects) {
View Full Code Here

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

            } else {
                configStream =
                        config.getServletContext().getResourceAsStream("/WEB-INF/registry.xml");
            }

            RegistryContext registryContext = RegistryContext.getBaseInstance(configStream,
                    new RegistryContext.RegURLSupplier() {
                        public String getURL() {
                            return config.getServletContext().getRealPath("/WEB-INF");
                        }
                    });

            embeddedRegistryService = registryContext.getEmbeddedRegistryService();

            // create a system registry and put it in the context
            UserRegistry systemRegistry = embeddedRegistryService.getConfigSystemRegistry();

            // add configured handers to the jdbc registry
            // note: no need to do this here. this is done inside the registry context
            //Iterator<HandlerConfiguration> handlers =
            //        registryContext.getHandlerConfigurations().iterator();
            //while (handlers.hasNext()) {
            //    HandlerConfiguration handlerConfiguration = handlers.next();
            //    registryContext.getHandlerManager().addHandler(0,
            //            handlerConfiguration.getFilter(), handlerConfiguration.getHandler());
            //}

            // create system resources

            NodeGroupLock.lock(NodeGroupLock.INITIALIZE_LOCK);

            if (log.isTraceEnabled()) {
                log.trace("Creating system collections used in WSO2 Registry server.");
            }

            if (!systemRegistry.resourceExists("/system")) {

                try {
                    boolean inTransaction = Transaction.isStarted();
                    if (!inTransaction) {
                        systemRegistry.beginTransaction();
                    }
                    Collection systemCollection = systemRegistry.newCollection();
                    String systemDesc = "This collection is used to store system data of the " +
                            "WSO2 Registry server. User nor the admins of the registry are not expected " +
                            "to edit any content of this collection. Changing content of this collection " +
                            "may result in unexpected behaviors.";
                    systemCollection.setDescription(systemDesc);
                    systemRegistry.put("/system", systemCollection);

                    Collection advancedQueryCollection = systemRegistry.newCollection();
                    String advaceDesc = "This collection is used to store auto generated queries " +
                            "to support various combinations of advanced search criteria. " +
                            "This is initialy empty and gets filled as advanced search is " +
                            "executed from the web UI.";
                    advancedQueryCollection.setDescription(advaceDesc);
                    systemRegistry.put("/system/queries/advanced", advancedQueryCollection);
                    if (!inTransaction) {
                        systemRegistry.commitTransaction();
                    }
                } catch (Exception e) {
                    String msg = "Unable to setup system collections used by the Carbon server.";
                    log.error(msg, e);
                    systemRegistry.rollbackTransaction();
                    throw new RegistryException(e.getMessage(), e);
                }
            }

            try {
                AuthorizationManager ac = systemRegistry.getUserRealm().getAuthorizationManager();
                RealmConfiguration realmConfig;
                realmConfig = registryContext.getRealmService().getBootstrapRealmConfiguration();
                String systemUserName = CarbonConstants.REGISTRY_SYSTEM_USERNAME;


                ac.clearResourceAuthorizations("/system");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.