当前位置: 首页>>代码示例>>Java>>正文


Java UserRegistry.resourceExists方法代码示例

本文整理汇总了Java中org.wso2.carbon.registry.core.session.UserRegistry.resourceExists方法的典型用法代码示例。如果您正苦于以下问题:Java UserRegistry.resourceExists方法的具体用法?Java UserRegistry.resourceExists怎么用?Java UserRegistry.resourceExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.registry.core.session.UserRegistry的用法示例。


在下文中一共展示了UserRegistry.resourceExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVerifiedChallenges

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * gets no of verified user challenges
 *
 * @param userDTO bean class that contains user and tenant Information
 * @return no of verified challenges
 * @throws IdentityException if fails
 */
public static int getVerifiedChallenges(UserDTO userDTO) throws IdentityException {

    int noOfChallenges = 0;

    try {
        UserRegistry registry = IdentityMgtServiceComponent.getRegistryService().
                getConfigSystemRegistry(MultitenantConstants.SUPER_TENANT_ID);
        String identityKeyMgtPath = IdentityMgtConstants.IDENTITY_MANAGEMENT_CHALLENGES +
                RegistryConstants.PATH_SEPARATOR + userDTO.getUserId() +
                RegistryConstants.PATH_SEPARATOR + userDTO.getUserId();

        Resource resource;
        if (registry.resourceExists(identityKeyMgtPath)) {
            resource = registry.get(identityKeyMgtPath);
            String property = resource.getProperty(IdentityMgtConstants.VERIFIED_CHALLENGES);
            if (property != null) {
                return Integer.parseInt(property);
            }
        }
    } catch (RegistryException e) {
        log.error("Error while processing userKey", e);
    }

    return noOfChallenges;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:Utils.java

示例2: getDecryptedPropertyValue

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * Method to decrypt a property, when key of the property is provided.
 *
 * @param key			key of the property.
 * @return 				decrypted property value.
 * @throws RegistryException	Throws when an error occurs during decryption.
 */
public static String getDecryptedPropertyValue(String key) throws RegistryException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    UserRegistry registry = SecurityServiceHolder.getInstance().getRegistryService()
            .getConfigSystemRegistry(tenantId);

    if (registry.resourceExists(SecureVaultConstants.ENCRYPTED_PROPERTY_STORAGE_PATH)) {
        Resource registryResource = registry.get(SecureVaultConstants.ENCRYPTED_PROPERTY_STORAGE_PATH);
        String propertyValue = registryResource.getProperty(key);
        if (propertyValue != null) {
            try {
                return doDecrypt(propertyValue);
            } catch (CryptoException | UnsupportedEncodingException e) {
                throw new RegistryException("Error while decrypting the property value", e);
            }
        } else {
            throw new RegistryException("Property does not exist with key \"" + key + "\" at path " +
                    SecureVaultConstants.ENCRYPTED_PROPERTY_CONFIG_REGISTRY_PATH);
        }
    } else {
        throw new RegistryException("Collection does not exist at path "
                + SecureVaultConstants.ENCRYPTED_PROPERTY_CONFIG_REGISTRY_PATH);
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:31,代码来源:SecureVaultUtil.java

示例3: getSubscription

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Subscription getSubscription(String id) throws EventBrokerException {

    try {
        UserRegistry userRegistry =
                this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance()
                                                                         .getTenantId());
        Resource topicIndexResource = userRegistry.get(this.indexStoragePath);
        String subscriptionPath = getResourcePath(id, topicIndexResource.getProperty(id));
        if (subscriptionPath != null && userRegistry.resourceExists(subscriptionPath)) {
            Resource subscriptionResource = userRegistry.get(subscriptionPath);
            Subscription subscription = JavaUtil.getSubscription(subscriptionResource);
            subscription.setTenantId(EventBrokerHolder.getInstance().getTenantId());
            return subscription;
        } else {
            return null;
        }
    } catch (RegistryException e) {
        throw new EventBrokerException("Cannot access the registry ", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-messaging,代码行数:25,代码来源:RegistrySubscriptionManager.java

示例4: getEventTypes

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public EventTypeBean getEventTypes(String path, String sessionId) throws RegistryException {
        UserRegistry registry = (UserRegistry) getRootRegistry();
        Resource resource = null;
        if (!path.startsWith(SubscriptionBeanPopulator.RECURSE)) {
            if (registry.resourceExists(path)) {
                resource = registry.get(path);
            }
        }
        if (resource != null) {
            String isLink = resource.getProperty("registry.link");
            String mountPoint = resource.getProperty("registry.mountpoint");
            String targetPoint = resource.getProperty("registry.targetpoint");
            String actualPath = resource.getProperty("registry.actualpath");
            if (isLink != null && mountPoint != null && targetPoint != null) {
//                path = path.replace(mountPoint, targetPoint);
                path = actualPath;
            }
        }
        return EventTypeBeanPopulator.populate(registry, path);
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:21,代码来源:InfoService.java

示例5: validateDomainFromSuccessKey

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * validates domain from the successkey
 *
 * @param governanceSystemRegistry - The governance system registry
 * @param domain                   - tenant domain
 * @param successKey               - successkey
 * @return true, if successfully validated
 * @throws RegistryException, if validation failed
 */
public static boolean validateDomainFromSuccessKey(UserRegistry governanceSystemRegistry,
                                                   String domain, String successKey)
        throws RegistryException {
    String domainValidatorInfoPath =
            StratosConstants.DOMAIN_VALIDATOR_INFO_PATH + RegistryConstants.PATH_SEPARATOR +
            domain + RegistryConstants.PATH_SEPARATOR +
            StratosConstants.VALIDATION_KEY_RESOURCE_NAME;
    if (governanceSystemRegistry.resourceExists(domainValidatorInfoPath)) {
        Resource resource = governanceSystemRegistry.get(domainValidatorInfoPath);
        String actualSuccessKey = resource.getProperty("successKey");
        if (actualSuccessKey != null && successKey != null &&
            actualSuccessKey.trim().equals(successKey.trim())) {
            // the domain is correct
            return true;
        }
    }
    return false;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:28,代码来源:CommonUtil.java

示例6: getPaginatedTopicTree

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public TopicNode getPaginatedTopicTree(String topicPath, int startIndex, int numberOfTopicsPerRound) throws
        EventBrokerException {
    try {
        UserRegistry userRegistry =
                this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
        if (!userRegistry.resourceExists(topicPath)) {
            userRegistry.put(topicPath, userRegistry.newCollection());
        }
        Collection collection = (Collection) userRegistry.get(topicPath);
        String[] paths = collection.getChildren(startIndex, numberOfTopicsPerRound);
        TopicNode rootTopic = new TopicNode("/", "/");
        buildTopicTree(rootTopic, paths);
        return rootTopic;
    } catch (RegistryException e) {
        throw new EventBrokerException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-messaging,代码行数:22,代码来源:TopicManagerServiceImpl.java

示例7: removeTopic

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean removeTopic(String topicName) throws EventBrokerException {

    try {
        UserRegistry userRegistry =
                this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
        String resourcePath = JavaUtil.getResourcePath(topicName, this.topicStoragePath);

        removeRoleCreateForLoggedInUser(topicName);

        if (userRegistry.resourceExists(resourcePath)) {
            userRegistry.delete(resourcePath);
            return true;
        } else {
            return false;
        }
    } catch (RegistryException e) {
        throw new EventBrokerException("Cannot access the config registry", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:24,代码来源:RegistryTopicManager.java

示例8: validateDomainFromSuccessKey

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * validates domain from the successkey
 *
 * @param governanceSystemRegistry - The governance system registry
 * @param domain                   - tenant domain
 * @param successKey               - successkey
 * @return true, if successfully validated
 * @throws RegistryException, if validation failed
 */
public static boolean validateDomainFromSuccessKey(UserRegistry governanceSystemRegistry,
                                                   String domain, String successKey)
        throws RegistryException {
    String domainValidatorInfoPath =
            StratosConstants.DOMAIN_VALIDATOR_INFO_PATH + RegistryConstants.PATH_SEPARATOR +
                    domain + RegistryConstants.PATH_SEPARATOR +
                    StratosConstants.VALIDATION_KEY_RESOURCE_NAME;
    if (governanceSystemRegistry.resourceExists(domainValidatorInfoPath)) {
        Resource resource = governanceSystemRegistry.get(domainValidatorInfoPath);
        String actualSuccessKey = resource.getProperty("successKey");
        if (actualSuccessKey != null && successKey != null &&
                actualSuccessKey.trim().equals(successKey.trim())) {
            // the domain is correct
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:stratos,代码行数:28,代码来源:CommonUtil.java

示例9: getRemoteURL

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public String getRemoteURL(String path, String sessionId) throws RegistryException {
    UserRegistry registry = (UserRegistry) getRootRegistry();
    if (registry.resourceExists(path)) {
        Resource resource = registry.get(path);
        if (resource != null) {
            String isLink = resource.getProperty("registry.link");
            String realPath = resource.getProperty("registry.realpath");
            String userName = resource.getProperty("registry.user");
            if (isLink != null && realPath != null && userName != null) {
                log.debug("Found mounted resource at: " + realPath);
                if (!realPath.contains("/registry/resourceContent?")) {
                    return null;
                }
                boolean isLocalMount = false;
                try {
                    isLocalMount = ResourceUtil.isLocalMount(realPath);
                } catch (RegistryException e) {
                    log.error("Unable to check whether resource is locally mounted", e);
                }
                if(!isLocalMount) {
                    return realPath.replace("/registry/resourceContent?", "/carbon/resources/resource.jsp?region=region3&item=resource_browser_menu&viewType=std&");
                }
            }
        }
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:28,代码来源:InfoService.java

示例10: init

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public void init(int tenantId) throws DeploymentSynchronizerException {

        try {
            UserRegistry configRegistry = getConfigurationRegistry(tenantId);
            String tenantRegistryPath = getRegistryPath(tenantId);

            this.registry = configRegistry;
            this.registryPath = tenantRegistryPath;
            this.basePath = RegistryConstants.CONFIG_REGISTRY_BASE_PATH;

            if (!configRegistry.resourceExists(tenantRegistryPath)) {
                Collection collection = configRegistry.newCollection();
                configRegistry.put(tenantRegistryPath, collection);
                collection.discard();
            }

        } catch (RegistryException e) {
            throw new DeploymentSynchronizerException("Error while accessing registry for " +
                    "tenant: " + tenantId, e);
        }

//        try {
//            if (!registry.resourceExists(registryPath)) {
//                Collection collection = registry.newCollection();
//                registry.put(registryPath, collection);
//                collection.discard();
//            }
//        } catch (RegistryException e) {
//            handleException("Error while creating the registry collection at: " + registryPath, e);
//        }
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:32,代码来源:RegistryBasedArtifactRepository.java

示例11: validate

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public boolean validate(RequestContext context) {
    if (attributes.length == 0) {
        return true;
    }
    String resourcePath = context.getResourcePath().getPath();
    int index = resourcePath.indexOf(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
    if (index < 0) {
        log.warn("Unable to use Validator For Resource Path: " + resourcePath);
        return false;
    }
    index += RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH.length();
    if (resourcePath.length() <= index) {
        log.warn("Unable to use Validator For Resource Path: " + resourcePath);
        return false;
    }
    resourcePath = resourcePath.substring(index);
    try {
        UserRegistry registry = ((UserRegistry) context.getSystemRegistry());
        if (!registry.resourceExists(resourcePath)) {
            registry = ((UserRegistry) context.getSystemRegistry())
                    .getChrootedRegistry(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
        }
        GovernanceArtifact governanceArtifact =
                GovernanceUtils.retrieveGovernanceArtifactByPath(registry, resourcePath);
        for (String attribute : attributes) {
            if (!validateAttribute(governanceArtifact, attribute)) {
                return false;
            }
        }
    } catch (RegistryException e) {
        log.error("Unable to obtain registry instance", e);
    }
    return true;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:35,代码来源:AttributeExistenceValidator.java

示例12: isTopicExists

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean isTopicExists(String topicName) throws EventBrokerException {
    try {
        UserRegistry userRegistry =
                this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
        String resourcePath = JavaUtil.getResourcePath(topicName, this.topicStoragePath);
        return userRegistry.resourceExists(resourcePath);
    } catch (RegistryException e) {
        throw new EventBrokerException("Cannot access the config registry");
    }
}
 
开发者ID:wso2,项目名称:carbon-business-messaging,代码行数:15,代码来源:TopicManagerServiceImpl.java

示例13: RegistrySubscriptionManager

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * Adds topic storage path and index storage path to user registry.
 *
 * @param topicStoragePath topic storage path. the path where topics will be stored.
 * @param indexStoragePath index storage path.
 * @throws EventBrokerConfigurationException
 */
public RegistrySubscriptionManager(String topicStoragePath, String indexStoragePath)
        throws EventBrokerConfigurationException {

    this.registryService = EventBrokerHolder.getInstance().getRegistryService();
    this.topicStoragePath = topicStoragePath;
    this.indexStoragePath = indexStoragePath;

    // creates the the subscription index
    // when creating subscriptions we going to add entries to this this resource
    try {
        UserRegistry userRegistry =
                this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance()
                                                                         .getTenantId());

        //create the topic storage path if it does not exists
        if (!userRegistry.resourceExists(this.topicStoragePath)) {
            userRegistry.put(this.topicStoragePath, userRegistry.newCollection());
        }

        // we need to create the index here only it is not exists.
        if (!userRegistry.resourceExists(this.indexStoragePath)) {
            userRegistry.put(this.indexStoragePath, userRegistry.newResource());
        }

    } catch (RegistryException e) {
        throw new EventBrokerConfigurationException("Cannot access the registry ", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-messaging,代码行数:36,代码来源:RegistrySubscriptionManager.java

示例14: persistConfiguration

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * Save the given DeploymentSynchronizerConfiguration to the registry. The target
 * configuration registry space will be selected using the specified tenant ID. As a result
 * the configuration will be stored in the configuration registry of the specified
 * tenant.
 *
 * @param config The configuration to be saved
 * @param tenantId Tenant ID to select the configuration registry
 * @throws org.wso2.carbon.registry.core.exceptions.RegistryException if an error occurs while accessing the registry
 */
public static void persistConfiguration(DeploymentSynchronizerConfiguration config,
                                        int tenantId) throws RegistryException {

    Resource resource;
    UserRegistry localRepository = getLocalRepository(tenantId);
    if (!localRepository.resourceExists(DeploymentSynchronizerConstants.CARBON_REPOSITORY)) {
        resource = localRepository.newResource();
    } else {
        resource = localRepository.get(DeploymentSynchronizerConstants.CARBON_REPOSITORY);
    }

    resource.setProperty(DeploymentSynchronizerConstants.AUTO_COMMIT_MODE,
            String.valueOf(config.isAutoCommit()));
    resource.setProperty(DeploymentSynchronizerConstants.AUTO_CHECKOUT_MODE,
            String.valueOf(config.isAutoCheckout()));
    resource.setProperty(DeploymentSynchronizerConstants.AUTO_SYNC_PERIOD,
            String.valueOf(config.getPeriod()));
    resource.setProperty(DeploymentSynchronizerConstants.USE_EVENTING,
            String.valueOf(config.isUseEventing()));
    resource.setProperty(DeploymentSynchronizerConstants.REPOSITORY_TYPE,
            config.getRepositoryType());
    resource.setContent(config.isEnabled() ? "enabled" : "disabled");

    //Get Repository specific configuration parameters from config object.
    RepositoryConfigParameter[] parameters = config.getRepositoryConfigParameters();

    if (parameters != null && parameters.length != 0) {
        //Save each Repository specific configuration parameter in registry.
        for (int i = 0; i < parameters.length; i++) {
            resource.setProperty(parameters[i].getName(), parameters[i].getValue());
        }
    }

    localRepository.put(DeploymentSynchronizerConstants.CARBON_REPOSITORY, resource);
    resource.discard();
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:47,代码来源:CarbonRepositoryUtils.java

示例15: getJMSSubscriptions

import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Subscription[] getJMSSubscriptions(String topicName) throws EventBrokerException {
    try {
        Subscription[] subscriptionsArray = new Subscription[0];

        UserRegistry userRegistry =
                this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
        String resourcePath = JavaUtil.getResourcePath(topicName, this.topicStoragePath);
        if (!resourcePath.endsWith("/")) {
            resourcePath = resourcePath + "/";
        }
        resourcePath = resourcePath + EventBrokerConstants.EB_CONF_JMS_SUBSCRIPTION_COLLECTION_NAME;

        // Get subscriptions
        if (userRegistry.resourceExists(resourcePath)) {
            Collection subscriptionCollection = (Collection) userRegistry.get(resourcePath);
            subscriptionsArray =
                    new Subscription[subscriptionCollection.getChildCount()];

            int index = 0;
            for (String subs : subscriptionCollection.getChildren()) {
                Collection subscription = (Collection) userRegistry.get(subs);

                Subscription subscriptionDetails = new Subscription();
                subscriptionDetails.setId(subscription.getProperty("Name"));
                subscriptionDetails.setOwner(subscription.getProperty("Owner"));
                subscriptionDetails.setCreatedTime(new Date(subscription.getCreatedTime().getTime()));
                subscriptionsArray[index++] = subscriptionDetails;
            }
        }

        return subscriptionsArray;
    } catch (RegistryException e) {
        throw new EventBrokerException("Cannot read the registry resources ", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-messaging,代码行数:40,代码来源:TopicManagerServiceImpl.java


注:本文中的org.wso2.carbon.registry.core.session.UserRegistry.resourceExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。