Package org.wso2.carbon.registry.core

Examples of org.wso2.carbon.registry.core.Registry


    }

    private void handleFileUpload(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        try {
            Registry registry = Utils.getSecureRegistry(request);
            ResourceImpl fileElement =
                    FileUploadUtil.processUpload(request);
            String path = fileElement.getPath();
            registry.put(path, fileElement);
            request.getSession().setAttribute(RegistryConstants.STATUS_MESSAGE_NAME,
                    "Resource " + path +
                            " was successfully added to the registry.");
            response.setContentType("text/html");
            request.getRequestDispatcher(RegistryConstants.RESOURCES_JSP)
View Full Code Here


    public void testNestedRegistryOperations() throws RegistryException {

        // get the realm config to retrieve admin username, password
        realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
        Registry adminRegistry = embeddedRegistryService.getUserRegistry(
            realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
        RegistryContext registryContext = adminRegistry.getRegistryContext();
        MyPrivateHandler myPrivateHandler = new MyPrivateHandler();

        HandlerManager handlerManager = registryContext.getHandlerManager();

        URLMatcher myPrivateHandlerMatcher = new URLMatcher();
        myPrivateHandlerMatcher.setGetPattern(".*/to/my/private/handler");
        myPrivateHandlerMatcher.setPutPattern(".*/to/my/private/handler");
        handlerManager.addHandler(
                new String[] {Filter.GET, Filter.PUT} , myPrivateHandlerMatcher, myPrivateHandler);

        Resource r = adminRegistry.newResource();
        String originalContent = "original content";
        r.setContent(originalContent.getBytes());

        adminRegistry.put("/to/my/private/handler", r);
        Resource rr = adminRegistry.get("/to/my/private/handler");

        byte[] newContent = (byte[])rr.getContent();
        String newContentString = new String(newContent);

        String expectedString = "<adminRegistry-output><systemRegistry-output>" +
View Full Code Here

        public Resource get(RequestContext requestContext) throws RegistryException {
            String path = requestContext.getResourcePath().getPath();
            String currentUser = CurrentSession.getUser();
            if (currentUser.equals(realmConfig.getAdminUserName())) {
                // we will get the system registry for this
                Registry systemRegistry = embeddedRegistryService.getSystemRegistry();
                Resource r = systemRegistry.get(path);
                byte[] content = (byte[])r.getContent();
                String contentString = new String(content);
                contentString = "<adminRegistry-output>" + contentString +
                        "</adminRegistry-output>";
                r.setContent(contentString.getBytes());
View Full Code Here

            String path = requestContext.getResourcePath().getPath();
            Resource r = requestContext.getResource();
            String currentUser = CurrentSession.getUser();
            if (currentUser.equals(realmConfig.getAdminUserName())) {
                // we will get the system registry for this
                Registry systemRegistry = embeddedRegistryService.getSystemRegistry();
                byte[] content = (byte[])r.getContent();
                String contentString = new String(content);
                contentString = "<adminRegistry-input>" + contentString +
                        "</adminRegistry-input>";
                r.setContent(contentString.getBytes());
                systemRegistry.put(path, r);
            } else {
                // now this should be the system registry, so lets return the real content
                Repository repository = requestContext.getRepository();
                byte[] content = (byte[])r.getContent();
                String contentString = new String(content);
View Full Code Here

     * @return the Registry instance.
     * @throws RegistryException if an error occurs.
     */
    protected Registry getRegistry(HttpServletRequest request) throws RegistryException {

        Registry registry =
                (Registry) request.getSession().getAttribute(
                        RegistryConstants.ROOT_REGISTRY_INSTANCE);

        if (registry == null) {
            registry = RegistryCoreServiceComponent.getRegistryService().getRegistry();
View Full Code Here

            if (realmService != null) {
                RegistryUtils.getBootstrapRealm(realmService);
            }

            Registry systemRegistry = getSystemRegistry();
            RegistryUtils.addMountCollection(systemRegistry);

        } catch (MalformedURLException e) {
            log.fatal("Registry URL is malformed, Registry configuration must be invalid", e);
            throw new RegistryException("URL is malformed", e);
View Full Code Here

            userRealm1.getUserStoreManager().addUser("don1", "password", null, null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding a user", e);
        }

        Registry registry3 = embeddedRegistryService.getUserRegistry("don1", "password", 0);
        r = registry3.get("/");
        assertEquals("The property name should be value", r.getProperty("name"), "value");

        String[] children = (String[]) r.getContent();
        assertEquals("child should be /test", children[0], "/test");
View Full Code Here

                    .getComponentConfig(ManagementPermissionsBuilder.LOCALNAME_MGT_PERMISSIONS);
        }

        if (uiPermissions != null) {
            // at the starup we are only adding permission only to tenant 0
            Registry registry = UserMgtDSComponent.getRegistryService().getGovernanceSystemRegistry();
            for (ManagementPermission uiPermission : uiPermissions) {
                if (registry.resourceExists(uiPermission.getResourceId())) {
                    continue;
                }
                Collection resource = registry.newCollection();
                resource.setProperty(UserMgtConstants.DISPLAY_NAME, uiPermission.getDisplayName());
                registry.put(uiPermission.getResourceId(), resource);
            }
        }
    }
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

    }

    // Sets-up the media types for this instance.
    private static void setupMediaTypes(RegistryService registryService, int tenantId) {
        try {
            Registry registry = registryService.getConfigSystemRegistry(tenantId);
            MediaTypesUtils.getResourceMediaTypeMappings(registry);
            MediaTypesUtils.getCustomUIMediaTypeMappings(registry);
            MediaTypesUtils.getCollectionMediaTypeMappings(registry);
        } catch (RegistryException e) {
            log.error("Unable to create fixed remote mounts.", e);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.Registry

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.