Package org.wso2.carbon.registry.core

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


    // Sets-up the mounts for this instance.
    private void setupMounts(RegistryService registryService, int tenantId) {
        try {
            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())) {
                    if (isSuperTenant) {
                        superTenantRegistry.createLink(mount.getPath(), mount.getInstanceId(),
                                mount.getTargetPath());
                    } else {
                        createPseudoLink(registry, mount.getPath(), mount.getInstanceId(),
                                mount.getTargetPath());
                        addFixedMount(tenantId, superTenantRegistry, mount.getPath());
                    }
                    defineFixedMount(registry, mount.getPath(), isSuperTenant);
                } else if (mount.isOverwrite()) {
                    registry.delete(mount.getPath());
                    if (isSuperTenant) {
                        superTenantRegistry.createLink(mount.getPath(), mount.getInstanceId(),
                                mount.getTargetPath());
                    } else {
                        createPseudoLink(registry, mount.getPath(), mount.getInstanceId(),
                                mount.getTargetPath());
                        addFixedMount(tenantId, superTenantRegistry, mount.getPath());
                    }
                    defineFixedMount(registry, mount.getPath(), isSuperTenant);
                } else if (mount.isVirtual()) {
                    Resource r = registry.get(mount.getPath());
                    if (Boolean.toString(true).equals(r.getProperty(
                            RegistryConstants.REGISTRY_LINK))) {
                        log.error("Unable to create virtual remote mount at location: " +
                                mount.getPath() + ". Virtual remote mounts can only be created " +
                                "for physical resources.");
                        continue;
                    } else {
                        if (isSuperTenant) {
                            superTenantRegistry.createLink(mount.getPath(), mount.getInstanceId(),
                                    mount.getTargetPath());
                        } else {
                            createPseudoLink(registry, mount.getPath(), mount.getInstanceId(),
                                    mount.getTargetPath());
                            addFixedMount(tenantId, superTenantRegistry, mount.getPath());
                        }
                        defineFixedMount(registry, mount.getPath(), isSuperTenant);
                    }
                } else {
                    log.error("Unable to create remote mount. A resource already exists at the " +
                            "given location: " + mount.getPath());
                    continue;
                }
                try {
                    if (!registry.resourceExists(mount.getPath())) {
                        log.warn("Target path does not exist for the given mount: " +
                                mount.getPath());
                    }
                } catch (Exception e) {
                    log.warn("Target path does not exist for the given mount: " +
View Full Code Here


     */
    public void registerBuiltInHandlers(RegistryService registryService) throws RegistryException {
        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.");
        }
View Full Code Here

                {
                    setRealmService(embeddedRegistryService.getRealmService());
                }
            };
            component.registerBuiltInHandlers(embeddedRegistryService);
            Registry registry = embeddedRegistryService.getConfigSystemRegistry();
            Registry governanceRegistry = embeddedRegistryService.getGovernanceSystemRegistry();
            SecurityServiceHolder.setRegistryService(embeddedRegistryService);

            //create an axisconfig object using an axis2.xml
            ConfigurationContext configContext = ConfigurationContextFactory
                    .createConfigurationContextFromFileSystem(REPO_PATH);
View Full Code Here

            param.setValue(paramValue);
        } else {
            axisModule.addParameter(new Parameter(paramName,paramValue));
        }

        Registry registry = getConfigSystemRegistry();
        try {
            String resourcePath = moduleResourcePath + RegistryResources.PARAMETERS + paramName;
            Resource paramResource = null;
            if (registry.resourceExists(resourcePath)) {
                paramResource = registry.get(resourcePath);
                paramResource.setContent("<parameter name=\"" + paramName + "\" locked=\"false\">" + paramValue + "</parameter>");
                registry.put(resourcePath, paramResource);
            } else {
                paramResource = registry.newResource();
                paramResource.setContent("<parameter name=\"" + paramName + "\" locked=\"false\">" + paramValue + "</parameter>");
                paramResource.addProperty(RegistryResources.NAME, paramName);
                registry.put(resourcePath, paramResource);
            }

        } catch (RegistryException e) {
            throw new AxisFault("Problem when setting parameter values");
        }
View Full Code Here

            return;
        }

        ProxyService proxyService = config.getProxyService(axisService.getName());
        try {
            Registry registry = this.configSystemRegistry;
            String servicePath = RegistryResources.ROOT + "axis2" +
                    RegistryConstants.PATH_SEPARATOR + "service-groups" +
                    RegistryConstants.PATH_SEPARATOR +
                    axisService.getAxisServiceGroup().getServiceGroupName() +
                    RegistryConstants.PATH_SEPARATOR + "services" +
                    RegistryConstants.PATH_SEPARATOR + axisService.getName();

            String servicePoliciesPath = servicePath
                    + RegistryConstants.PATH_SEPARATOR + "policies";

            List<PolicyInfo> remainingPolicies = new ArrayList<PolicyInfo>();
            for (PolicyInfo info : proxyService.getPolicies()) {
                if (!info.getPolicyKey().startsWith("conf:" + servicePoliciesPath)) {
                    remainingPolicies.add(info);
                }
            }
            proxyService.setPolicies(remainingPolicies);

            if (registry.resourceExists(servicePoliciesPath)) {
                // there are service level policies
                Resource servicePoliciesResource = registry.get(servicePoliciesPath);
                if (servicePoliciesResource instanceof Collection) {
                    Collection servicePoliciesCollection = (Collection) servicePoliciesResource;
                    for (String servicePolicyResourcePath :
                            servicePoliciesCollection.getChildren()) {
                        PolicyInfo pi = handlePolicy(config,
View Full Code Here

        }
    }

    private void updatePolicy(String moduleResourcePath,
                              SandeshaPolicyBean sandeshaPolicyBean) throws AxisFault {
        Registry registry = getConfigSystemRegistry();
        Policy sandeshaPolicy = new Policy();
        sandeshaPolicy.setId("RMPolicy");
        sandeshaPolicy.setName("RMPolicy");
        sandeshaPolicy.addPolicyComponent(sandeshaPolicyBean);

        try {
            String resourcePath = moduleResourcePath + RegistryResources.POLICIES + sandeshaPolicy.getId();
            Resource policyResource = null;
            if (registry.resourceExists(resourcePath)) {
                policyResource = registry.get(resourcePath);
            } else {
                policyResource = registry.newResource();
                policyResource.setProperty(RegistryResources.ServiceProperties.POLICY_TYPE,
                        String.valueOf(PolicyInclude.SERVICE_POLICY));
                policyResource.setProperty(RegistryResources.ServiceProperties.POLICY_UUID, "RMPolicy");
            }

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
            sandeshaPolicy.serialize(writer);
            writer.flush();
            policyResource.setContent(baos.toString());
            registry.put(resourcePath, policyResource);

        } catch (RegistryException e) {
            throw new AxisFault("Problem when setting parameter values");
        } catch (XMLStreamException e) {
            throw new AxisFault("Problem when setting parameter values");
View Full Code Here

        ServiceReference reference = context.getServiceReference(RegistryService.class
                .getName());
        RegistryService registryService = (RegistryService) context.getService(reference);
        String url = null;
        try {
            Registry systemRegistry = registryService.getConfigSystemRegistry();
            Resource resource = systemRegistry.get("/carbon/connection/props");
            String servicePath = resource.getProperty("service-path");
            String contextRoot = resource.getProperty("context-root");
            contextRoot = contextRoot.equals("/") ? "" : contextRoot;
            url = contextRoot + servicePath + "/Java2WSDLService";
        } catch (Exception e) {
View Full Code Here

    public static ConfirmationBean confirmUser(String secretKey) throws Exception {
        ConfirmationBean confirmationBean = new ConfirmationBean();
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMElement data = fac.createOMElement("configuration", null);

        Registry registry = Util.getConfigSystemRegistry(0);
        boolean success = false;
        try {
            registry.beginTransaction();

            String secretKeyPath = AdminMgtConstants.ADMIN_MANAGEMENT_COLLECTION + "/" + secretKey;
            if (!registry.resourceExists(secretKeyPath)) {
                String msg = "Failed Admin account management attempt.";
                log.error(msg);
                throw new Exception(msg);
            }
            Resource resource = registry.get(secretKeyPath);

            // just get the properties of that
            Properties props = resource.getProperties();
            for (Object o : props.keySet()) {
                String key = (String) o;
                OMElement internal = fac.createOMElement(key, null);
                internal.setText(resource.getProperty(key));
                data.addChild(internal);
                if (key.equals("redirectPath")) {
                    confirmationBean.setRedirectPath(resource.getProperty(key));
                }
            }

            // removing the temporarily stored data from the registry
            registry.delete(resource.getPath());

            confirmationBean.setData(data.toString());
            success = true;

        } finally {
            if (success) {
                registry.commitTransaction();
            } else {
                registry.rollbackTransaction();
            }
        }
        return confirmationBean;
    }
View Full Code Here

        try {
            String secretKey = UUID.randomUUID().toString();

            // The password reset request hasn't been verified by the tenant yet.
            // Hence using the super tenant registry instance
            Registry registry = Util.getConfigSystemRegistry(0);
            Resource resource = registry.newResource();
            // store the redirector url
            resource.setProperty("redirectPath", serviceConfig.getRedirectPath());
            // store the user data, redirectPath can be overwritten here.
            for (String s : data.keySet()) {
                resource.setProperty(s, data.get(s));
            }

            ((ResourceImpl) resource).setVersionableChange(false);
            String secretKeyPath = AdminMgtConstants.ADMIN_MANAGEMENT_COLLECTION + "/" + secretKey;
            registry.put(secretKeyPath, resource);
            // sending the mail
            EmailSender sender = new EmailSender(serviceConfig, emailAddress, secretKey,
                    SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true), userParams);
            sender.sendEmail();
        } catch (Exception e) {
View Full Code Here

        return EndpointUtils.getEndpointLocation() + urlToPath;
    }

    public static Registry getUnchrootedSystemRegistry(RequestContext requestContext)
            throws RegistryException {
        Registry registry = requestContext.getRegistry();
        RealmService realmService = registry.getRegistryContext().getRealmService();
        String systemUser = CarbonConstants.REGISTRY_SYSTEM_USERNAME;

        return new UserRegistry(systemUser, CurrentSession.getTenantId(), registry,
                realmService, null);
    }
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.