Examples of RegistryContext


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

        return sb.toString();
    }

    // Obtains a registry instance to work with, based on the configuration
    private Registry getRegistry(RequestContext requestContext) throws Exception {
        RegistryContext baseContext = RegistryContext.getBaseInstance();
        if (!isHandlerRegistered && baseContext != null) {
            try {              
                Registry systemRegistry = new UserRegistry(CarbonConstants.REGISTRY_SYSTEM_USERNAME,
                        CurrentSession.getTenantId(), requestContext.getRegistry(),
                        baseContext.getRealmService(), baseContext.getRegistryRoot());

                if (subPath != null) {
                    RegistryUtils.addMountEntry(systemRegistry, RegistryContext.getBaseInstance(),
                            mountPoint, id, subPath, author);
                } else {
                    RegistryUtils.addMountEntry(systemRegistry, RegistryContext.getBaseInstance(),
                            mountPoint, id, true, author);
                }
                isHandlerRegistered = true;
            } catch (RegistryException e) {
                log.error("Unable to add mount entry into Registry", e);
            }
        }
        if (remote) {
            if (registryProvider == null && registryType != null) {
                BundleContext bundleContext = RegistryCoreServiceComponent.getBundleContext();
                if (bundleContext != null) {
                    ServiceTracker tracker =
                            new ServiceTracker(bundleContext, RegistryProvider.class.getName(),
                                    null);
                    tracker.open();
                    ServiceReference[] references = tracker.getServiceReferences();
                    if (references != null) {
                        for (ServiceReference reference : references) {
                            if (registryType.equals(reference.getProperty("type"))) {
                                registryProvider = (RegistryProvider) tracker.getService(reference);
                                break;
                            }
                        }
                    }
                    tracker.close();
                }
            }

            if (registryProvider != null) {
                return registryProvider.getRegistry(this.conURL, this.userName, this.password);
            }

            RegistryUtils.setTrustStoreSystemProperties();
            return new RemoteRegistry(this.conURL, this.userName, this.password);
        }
        if (registryService == null) {
            RegistryContext context = RegistryContext.getCloneContext();
            context.setRegistryRoot(registryRoot);
            context.setReadOnly(readOnly);
            context.setCacheEnabled(cacheEnabled);
            context.selectDBConfig(dbConfig);
            registryService = context.getEmbeddedRegistryService();
        }
        return registryService.getUserRegistry(CurrentSession.getUser(),
                CurrentSession.getCallerTenantId());
    }
View Full Code Here

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

        if (isInExecution()) {
            return super.getRegistryContext(requestContext);
        } else {
            setInExecution(true);
        }
        RegistryContext registryContext;
        Registry remoteRegistry;
        try {
            remoteRegistry = getRegistry(requestContext);
            beginNestedOperation(new HashMap<String, String>());
            try {
View Full Code Here

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

            return;
        } else {
            setInExecution(true);
        }
        String fullPath = requestContext.getResourcePath().getPath();
        RegistryContext registryContext = requestContext.getRegistryContext();
        if (fullPath.equals(this.mountPoint)) {
            requestContext.getRegistry().removeLink(requestContext.getResource().getPath());
            if (registryContext != null) {
                HandlerManager hm = registryContext.getHandlerManager();
                hm.removeHandler(this,
                        HandlerLifecycleManager.TENANT_SPECIFIC_SYSTEM_HANDLER_PHASE);
            }
        } else {
            String actualPath = fullPath.substring(this.mountPoint.length(), fullPath.length());
View Full Code Here

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

        } else {
            setInExecution(true);
        }
        String fullResourcePath = requestContext.getSourcePath();
        String fullTargetPath = requestContext.getTargetPath();
        RegistryContext registryContext = requestContext.getRegistryContext();

        String newPath;
        if (fullResourcePath.equals(this.mountPoint)) {
            newPath = requestContext.getRepository()
                    .rename(new ResourcePath(fullResourcePath), fullTargetPath);
            requestContext.getRegistry().createLink(fullTargetPath, this.id);
            requestContext.getRegistry().removeLink(this.mountPoint);
            if (registryContext != null) {
                HandlerManager hm = registryContext.getHandlerManager();
                hm.removeHandler(this,
                        HandlerLifecycleManager.TENANT_SPECIFIC_SYSTEM_HANDLER_PHASE);
            }
        } else {
            String actualResourcePath = fullResourcePath.substring(
View Full Code Here

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

        } else {
            setInExecution(true);
        }
        String fullResourcePath = requestContext.getSourcePath();
        String fullTargetPath = requestContext.getTargetPath();
        RegistryContext registryContext = requestContext.getRegistryContext();

        try {
            if (fullResourcePath.equals(this.mountPoint)) {
                requestContext.getRepository()
                        .move(new ResourcePath(fullResourcePath), fullTargetPath);
                requestContext.getRegistry().createLink(fullTargetPath, this.id);
                requestContext.getRegistry().removeLink(this.mountPoint);
                if (registryContext != null) {
                    HandlerManager hm = registryContext.getHandlerManager();
                    hm.removeHandler(this,
                            HandlerLifecycleManager.TENANT_SPECIFIC_SYSTEM_HANDLER_PHASE);
                }
            } else if (fullResourcePath.startsWith(this.mountPoint)) {
                String actualResourcePath = fullResourcePath.substring(
View Full Code Here

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

            chroot = "/";
        } else if (!chroot.endsWith("/")) {
            chroot += "/";
        }
        context.setResourcePath(new ResourcePath(chroot));
        RegistryContext output =
                registryContext.getHandlerManager().getRegistryContext(context);
        endDBQueryLog(2);
        if (output != null) {
            return output;
        }
View Full Code Here

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

* /projects/ids/config.xml;ratings:foo
*/
public class RatingURLHandler extends Handler {

    public Resource get(RequestContext requestContext) throws RegistryException {
        RegistryContext registryContext = requestContext.getRegistryContext();
        if (registryContext == null) {
            registryContext = RegistryContext.getBaseInstance();
        }
        ResourceDAO resourceDAO = registryContext.getDataAccessManager().getDAOManager().
                getResourceDAO();
        RatingsDAO ratingsDAO = registryContext.getDataAccessManager().getDAOManager().
                getRatingsDAO(StaticConfiguration.isVersioningRatings());

        ResourcePath resourcePath = requestContext.getResourcePath();

        String ratedUserName = resourcePath.getParameterValue("ratings");
View Full Code Here

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

public class CommentURLHandler extends Handler {

    private static final Log log = LogFactory.getLog(CommentURLHandler.class);

    public Resource get(RequestContext requestContext) throws RegistryException {
        RegistryContext registryContext = requestContext.getRegistryContext();
        if (registryContext == null) {
            registryContext = RegistryContext.getBaseInstance();
        }
        CommentsDAO commentsDAO = registryContext.getDataAccessManager().getDAOManager().
                getCommentsDAO(StaticConfiguration.isVersioningComments());
        ResourcePath resourcePath = requestContext.getResourcePath();

        String commentID = resourcePath.getParameterValue("comments");
        if (commentID != null) {
View Full Code Here

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

        return null;
    }

    public void delete(RequestContext requestContext) throws RegistryException {
        RegistryContext registryContext = requestContext.getRegistryContext();
        if (registryContext == null) {
            registryContext = RegistryContext.getBaseInstance();
        }
        CommentsDAO commentsDAO = registryContext.getDataAccessManager().getDAOManager().
                getCommentsDAO(StaticConfiguration.isVersioningComments());
        requestContext.setProcessingComplete(false);
        ResourcePath resourcePath = requestContext.getResourcePath();

        String commentID = resourcePath.getParameterValue("comments");
View Full Code Here

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

     * @param abdera the abdera instance.
     *
     * @throws Exception if an exception occurs.
     */
    public RegistryProvider(Abdera abdera) throws Exception {
        RegistryContext context = RegistryContext.getBaseInstance();
        if (context == null) {

            String msg = "Registry is not properly initialized. Registry context is not found.";
            log.error(msg);
            throw new RegistryException(msg);

            //InputStream is = null;
            //try {
            //    is = new FileInputStream("registry.xml");
            //} catch (FileNotFoundException e) {
            //    // no problem
            //}
            //context = new RegistryContext(is);
            //RegistryContext.setSingleton(context);
        }
        TargetType[] types = {RegistryResolver.TAGS_TYPE, RegistryResolver.LOGS_TYPE,
                RegistryResolver.RATINGS_TYPE, RegistryResolver.COMMENTS_TYPE,
                RegistryResolver.RENAME_TYPE, RegistryResolver.COPY_TYPE,
                RegistryResolver.MOVE_TYPE, RegistryResolver.TAG_URL_TYPE,
                RegistryResolver.ASSOCIATIONS_TYPE, RegistryResolver.RESTORE_TYPE,
                RegistryResolver.VERSIONS_TYPE, RegistryResolver.CHECKPOINT_TYPE,
                RegistryResolver.QUERY_TYPE, RegistryResolver.IMPORT_TYPE,
                RegistryResolver.DUMP_TYPE, RegistryResolver.COLLECTION_CUSTOM_TYPE,
                RegistryResolver.DELETE_TYPE, RegistryResolver.ASPECT_TYPE,
                ResponseTarget.RESPONSE_TYPE};
        RequestProcessor processor = new RegistryRequestProcessor();
        for (TargetType type : types) {
            this.requestProcessors.put(type, processor);
        }

        EmbeddedRegistryService embeddedRegistryService;
        try {
            embeddedRegistryService = Utils.getEmbeddedRegistryService();
        } catch (RegistryException e) {
            embeddedRegistryService = context.getEmbeddedRegistryService();
        }

        RegistryResolver resolver = new RegistryResolver(embeddedRegistryService, BASE_CONTEXT);
        adapter = new RegistryAdapter();

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.