Package org.wso2.carbon.registry.core

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


public class RegistryRepositoryFactory implements RepositoryFactory{
    private Repository regRepo;
    public Repository getRepository(Map map) throws RepositoryException {

        RemoteRegistry remoteRegistry;
        Registry registry; // an admin registry
        try {
            RemoteRegistryService remoteRegistryService = new RemoteRegistryService((String)map.get("registryURL"),(String)map.get("userName"),(String)map.get("password"));
            if(regRepo == null) {

                regRepo = new RegistryRepository(remoteRegistryService);
View Full Code Here


public class AnnouncementService {
    private static final String instIdPath = "/repository/components/org.wso2.carbon.instance-id/uuid";
    public String retrieveRegId() throws Exception {
        RegistryService registryService = Util.getRegistryService();
        Registry systemRegistry = registryService.getGovernanceSystemRegistry();
        String uuid = null;
        systemRegistry.beginTransaction();
        boolean isSuccess = false;
        try {
            if (systemRegistry.resourceExists(instIdPath)) {
                Resource resource = systemRegistry.get(instIdPath);
                byte[] uuidBytes = (byte[])resource.getContent();
                uuid = new String(uuidBytes);
            }
            if (uuid == null) {
                uuid = UUIDGenerator.generateUUID();
                Resource resource = systemRegistry.newResource();
                resource.setContent(uuid);
                systemRegistry.put(instIdPath, resource);
            }
            isSuccess = true;
        }
        finally {
            if (isSuccess) {
                systemRegistry.commitTransaction();
            }
            else {
                systemRegistry.rollbackTransaction();
            }
        }
        return uuid;
    }
View Full Code Here

     * @throws RegistryException Thrown if an error occurs while accessing the Registry
     */
    public boolean uploadSample(String sampleName) throws RegistryException {
        SuperTenantCarbonContext carbonContext =
                SuperTenantCarbonContext.getCurrentContext();
        Registry registry = (Registry) carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
        try {
            if (registry.resourceExists(getSamplePath(sampleName))) {
                return true;
            }
        } catch (Exception ignored) {
            // Ignore any exceptions that may occur in the process, and try to re-upload the sample
            // assuming that it is not already on the registry.
View Full Code Here

    webdavContext = (RegistryWebDavContext) session
        .getAttribute(WEBDAV_CONTEXT);

    if (webdavContext == null) {
      String[] credentails = retriveUserNameAndPassword(req);
      Registry registry;
      if (credentails != null) {
        registry = WebdavServiceComponet.getRegistryInstance(
            credentails[0], credentails[1]);
      } else {
        registry = WebdavServiceComponet
View Full Code Here

        if (!initialized && listenerManager != null && registryService != null) {
            initialized = true;
            try {
                // We can't get Registry from Utils, as the MessageContext is not available at
                // activation time.
                Registry systemRegistry = registryService.getConfigSystemRegistry();
                if (registry != null && registry == systemRegistry) {
                    return;
                }
                registry = systemRegistry;
                if (registry == null ||
View Full Code Here

        }
        //TODOD remove this
//        String userID = "admin";
//        String password = "admin";
       
        Registry registry = WebdavServiceComponet.getRegistryInstance(
            userID, password);

        webdavContext = new RegistryWebDavContext(registry, request.getContextPath());
        webdavContext.setEnviorment(enviorment);
        session.setAttribute(RegistryServlet.WEBDAV_CONTEXT, webdavContext);
View Full Code Here

        if (!states.containsKey(stateKey)) {
            throw new ResourceNotFoundException("The given key, " + stateKey + " does not " +
                    "correspond to a lifecycle state.");
        }
        String servicePath = RegistryUtils.getParentPath(path);
        Registry registry = requestContext.getRegistry();
        for (String majorVersion : getSortedChildrenList(servicePath, registry)) {
            try {
                Integer.parseInt(RegistryUtils.getResourceName(majorVersion));
                for (String minorVersion : getSortedChildrenList(majorVersion, registry)) {
                    try {
                        Integer.parseInt(RegistryUtils.getResourceName(minorVersion));
                        for (String patchVersion : getSortedChildrenList(minorVersion, registry)) {
                            try {
                                Integer.parseInt(RegistryUtils.getResourceName(patchVersion));
                                String serviceResourcePath = patchVersion +
                                        RegistryConstants.PATH_SEPARATOR + resourceKey;
                                Resource resource = registry.get(serviceResourcePath);
                                for (Object propKey : resource.getProperties().keySet()) {
                                    if (((String)propKey).matches(
                                            "^registry[.]lifecycle.*[.]state$")) {
                                        if (states.get(stateKey).equals(
                                                resource.getProperty((String)propKey))) {
View Full Code Here

        if (accessValidation == null) {
            accessValidation = new ThrottlingAccessValidation();
            throttlingDataContext.setAccessValidation(accessValidation);
        }
        try {
            Registry governanceSystemRegistry = Util.getSuperTenantGovernanceSystemRegistry();
            if (governanceSystemRegistry.resourceExists(tenantValidationInfoResourcePath)) {
                Resource tenantValidationInfoResource =
                        governanceSystemRegistry.get(tenantValidationInfoResourcePath);
                Properties properties = tenantValidationInfoResource.getProperties();
                Set<String> actions = MeteringAccessValidationUtils.getAvailableActions(properties);

                for (String action : actions) {
                    String blockActionStr =
View Full Code Here

                StratosConstants.TENANT_USER_VALIDATION_STORE_PATH +
                        RegistryConstants.PATH_SEPARATOR + tenantId;

        ThrottlingAccessValidation accessValidation = throttlingDataContext.getAccessValidation();
        try {
            Registry governanceSystemRegistry = Util.getSuperTenantGovernanceSystemRegistry();

            Resource tenantValidationInfoResource;
            if (governanceSystemRegistry.resourceExists(tenantValidationInfoResourcePath)) {
                tenantValidationInfoResource =
                        governanceSystemRegistry.get(tenantValidationInfoResourcePath);
            } else {
                tenantValidationInfoResource = governanceSystemRegistry.newResource();
            }

            Set<String> actions = accessValidation.getActions();
            for (String action : actions) {
                boolean blockAction = accessValidation.isTenantBlocked(action);
                String blockActionMsg = accessValidation.getTenantBlockedMsg(action);

                tenantValidationInfoResource.setProperty(MeteringAccessValidationUtils
                        .generateIsBlockedPropertyKey(action), blockAction ? "true" : "false");

                tenantValidationInfoResource.setProperty(MeteringAccessValidationUtils
                        .generateErrorMsgPropertyKey(action), blockActionMsg);
            }
            governanceSystemRegistry.put(tenantValidationInfoResourcePath,
                    tenantValidationInfoResource);
        } catch (RegistryException e) {
            String msg =
                    "Error in storing the tenant validation info.  tenant id: " + tenantId + ".";
            log.error(msg, e);
View Full Code Here

    /* (non-Javadoc)
   * @see org.wso2.carbon.registry.search.services.ISearchService#getAdvancedSearchResults(org.wso2.carbon.registry.search.beans.CustomSearchParameterBean)
   */
    public AdvancedSearchResultsBean getAdvancedSearchResults(CustomSearchParameterBean parameters) throws RegistryException {
        UserRegistry registry = (UserRegistry) getRootRegistry();
        Registry configSystemRegistry = getConfigSystemRegistry();

        return AdvancedSearchResultsBeanPopulator.populate(configSystemRegistry,registry,parameters);

    }
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.