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


Java Resource.addProperty方法代码示例

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


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

示例1: testEditingMultivaluedProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testEditingMultivaluedProperties() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("r1 content");
        r1.addProperty("p1", "v1");
        r1.addProperty("p1", "v2");
        r1.setProperty("test", "value2");
        r1.setProperty("test2", "value2");
        registry.put("/props/t3/r1", r1);

        Resource r1e1 = registry.get("/props/t3/r1");
        r1e1.setContent("r1 content");
        r1e1.editPropertyValue("p1", "v1", "v3");
        List list = r1e1.getPropertyValues("/props/t3/r");

        registry.put("/props/t3/r1", r1e1);

        Resource r1e2 = registry.get("/props/t3/r1");


        assertFalse("Property is not edited.", r1e2.getPropertyValues("p1").contains("v1"));
        assertTrue("Property is not edited.", r1e2.getPropertyValues("p1").contains("v3"));
        assertTrue("Wrong property is removed.", r1e2.getPropertyValues("p1").contains("v2"));


    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:27,代码来源:PropertiesTest.java

示例2: addEprToRegistry

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * when getting hosts from registry getHostsFromRegistry method will return
 * all the hosts in the registry. As like addHostToRegistry will add the
 * hostinfo to the registry
 * 
 * @param hostName
 *            The virtual host to be stored in the registry
 * @param webApp
 *            The webapp to be deployed in the virtual host
 * @throws Exception
 */
public void addEprToRegistry(String hostName, String webApp, String tenantDomain, String appName)
		throws Exception {

	try {
		registryService.beginTransaction();
		Resource hostResource = registryService.newResource();
		hostResource.addProperty(UrlMapperConstants.HostProperties.HOST_NAME, hostName);
		hostResource.addProperty(UrlMapperConstants.HostProperties.SERVICE_EPR, webApp);
		hostResource.addProperty(UrlMapperConstants.HostProperties.TENANT_DOMAIN, tenantDomain);
           hostResource.addProperty(UrlMapperConstants.HostProperties.APP_NAME, appName);
		registryService
				.put(UrlMapperConstants.HostProperties.HOSTINFO + hostName, hostResource);
		registryService.commitTransaction();
	} catch (Exception e) {
		registryService.rollbackTransaction();
		log.error("Unable to add the host", e);
		throw e;
	}
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:31,代码来源:RegistryManager.java

示例3: addDefaultAttributeToAssociations

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
private void addDefaultAttributeToAssociations(final GovernanceArtifact artifact) throws GovernanceException {
    try {
        if(mediaType.equals("application/vnd.wso2-soap-service+xml")) {

            Association[] associations = registry.getAllAssociations(artifact.getPath());

            for(Association association : associations) {
                String destinationPath = association.getDestinationPath();
                if(destinationPath.contains("wsdl")) {
                    String[] subPaths = destinationPath.split("/");
                    final String artifactName = subPaths[subPaths.length - 1];
                    GovernanceArtifact[] governanceArtifacts = searchArtifactsByGroupingAttribute(artifact, CommonConstants.WSDL_MEDIA_TYPE, artifactName);

                    if(governanceArtifacts != null && governanceArtifacts.length == 0) {
                        Resource wsdlResource = registry.get(destinationPath);
                        wsdlResource.addProperty("default", "true");
                        registry.put(destinationPath, wsdlResource);
                    }
                }
            }
        }
    } catch(RegistryException ex) {
        log.error("An error occurred while retrieving association of the resource " + artifact.getPath(), ex);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:26,代码来源:GovernanceArtifactManager.java

示例4: testRemovingMultivaluedProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testRemovingMultivaluedProperties() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("r1 content");
        r1.addProperty("p1", "v1");
        r1.addProperty("p1", "v2");
        registry.put("/props/t2/r1", r1);

        Resource r1e1 = registry.get("/props/t2/r1");
        r1e1.setContent("r1 content updated");
        r1e1.removePropertyValue("p1", "v1");
        registry.put("/props/t2/r1", r1e1);

        Resource r1e2 = registry.get("/props/t2/r1");

        assertFalse("Property is not removed.", r1e2.getPropertyValues("p1").contains("v1"));
        assertTrue("Wrong property is removed.", r1e2.getPropertyValues("p1").contains("v2"));
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:PropertiesTest.java

示例5: setTagSearchQuery

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * custom query for all the tags search is set as a resource and saved at
 * the config registry.space
 */
private boolean setTagSearchQuery() {
    if (log.isDebugEnabled()) {
        log.debug("tag search customs query is set");
    }
    String tagsQueryPath =
            RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                    RegistryConstants.QUERIES_COLLECTION_PATH + "/tags";
    try {
        if (!super.getUserRegistry().resourceExists(tagsQueryPath)) {
            // set-up query for tag-search.
            Resource resource = super.getUserRegistry().newResource();
            resource.setContent("SELECT RT.REG_TAG_ID FROM REG_RESOURCE_TAG RT ORDER BY "
                    + "RT.REG_TAG_ID");
            resource.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
            resource.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
                    RegistryConstants.TAGS_RESULT_TYPE);
            super.getUserRegistry().put(tagsQueryPath, resource);
        }
        return true;
    } catch (RegistryException e) {
        log.error(e.getCause(), e);
        return false;
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:29,代码来源:Tags.java

示例6: attachPropertyToResource

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Add/ edit a property value for the given Registry resource
 *
 * @param activityResource Registry resource to add/set property
 * @param properties       A Map consisting properties and it's values
 * @param isUpdate         True, if it is an update. False, if it is an addition
 */
private void attachPropertyToResource(Resource activityResource, Map<String, String> properties,
                                      boolean isUpdate) {


    for (Map.Entry<String, String> e : properties.entrySet()) {
        if (e.getValue() != null) {
            if (isUpdate) {
                String oldValue = activityResource.getProperty(e.getKey());
                activityResource.editPropertyValue(e.getKey(), oldValue, e.getValue());
            } else {
                activityResource.addProperty(e.getKey(), e.getValue());
            }
        }
    }

}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:24,代码来源:ActivityStreamManagerImpl.java

示例7: getAppDataAddedRegistryResource

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Adds/updates the Map of key-value pairs (appData) to the registry resource
 *
 * @param appDataResource The registry resource to add properties
 * @param values          The Map of key-value appData
 * @param isUpdate        true- if required to update the properties
 *                        false- if required to add the properties
 * @return The registry resource with the appData added as properties
 */

private Resource getAppDataAddedRegistryResource(Resource appDataResource,
                                                 Map<String, String> values, boolean isUpdate) {
    for (Map.Entry<String, String> e : values.entrySet()) {         /* for each key in the map */
        if (e.getValue() != null) {
            /* if (isUpdate) {*/
            String oldValue = appDataResource.getProperty(e.getKey());
            if (oldValue != null) {
                appDataResource.editPropertyValue(e.getKey(), oldValue, e.getValue());  /* edit properties to the resource */
            }
            /* } else {*/
            else {
                appDataResource.addProperty(e.getKey(), e.getValue());  /* add properties to the resource */
            }
            /* }*/
        }
    }
    return appDataResource;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:29,代码来源:AppDataManagerImpl.java

示例8: addLogger

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * when getting loggers from getCurrentLoggers method it will return all the
 * loggers in the system. this includes loggers we have initialized using
 * getLogger methods. but these loggers does not have a log level set they
 * get the log level from the parent loggers. but to store in registry we
 * use only loggers with a log level
 * <p/>
 * Store the provided Log4J Logger in the Registry
 *
 * @param logger The Log4J Logger to be stored in the registry
 */
public void addLogger(Logger logger) throws Exception {
    try {
        registry.beginTransaction();
        Resource loggerResource = registry.newResource();
        loggerResource.addProperty(LoggingConstants.LoggerProperties.NAME,
                logger.getName());
        loggerResource.addProperty(
                LoggingConstants.LoggerProperties.LOG_LEVEL, logger
                        .getEffectiveLevel().toString());
        loggerResource.addProperty(
                LoggingConstants.LoggerProperties.ADDITIVITY,
                Boolean.toString(logger.getAdditivity()));

        registry.put(LoggingConstants.LOGGERS + logger.getName(),
                loggerResource);
        registry.commitTransaction();
    } catch (Exception e) {
        registry.rollbackTransaction();
        log.error("Unable to add the logger", e);
        throw e;
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:34,代码来源:RegistryManager.java

示例9: testResourcePropertyVersioning

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testResourcePropertyVersioning() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("content 1");
        r1.addProperty("p1", "v1");
        registry.put("/v4/r1", r1);

        Resource r1v2 = registry.get("/v4/r1");
        r1v2.addProperty("p2", "v2");
        registry.put("/v4/r1", r1v2);

        String[] r1Versions = registry.getVersions("/v4/r1");

        Resource r1vv1 = registry.get(r1Versions[1]);

        assertEquals("r1's first version should contain a property p1 with value v1",
                r1vv1.getProperty("p1"), "v1");

        Resource r1vv2 = registry.get(r1Versions[0]);

        assertEquals("r1's second version should contain a property p1 with value v1",
                r1vv2.getProperty("p1"), "v1");

        assertEquals("r1's second version should contain a property p2 with value v2",
                r1vv2.getProperty("p2"), "v2");
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:27,代码来源:VersionHandlingTest.java

示例10: updateConfigurationProperty

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void updateConfigurationProperty(String propertyName, String value)
        throws RegistryException {
    if (propertyName == null || value == null) {
        return;
    }
    String resourcePath = RegistryResources.LOGGING + propertyName;
    Resource resource;
    if (!registry.resourceExists(resourcePath)) {
        resource = registry.newResource();
        resource.addProperty(propertyName, value);
        registry.put(resourcePath, resource);
    } else {
        resource = registry.get(resourcePath);
        String existingValue = resource.getProperty(propertyName);
        if (!(existingValue != null && existingValue.equals(value))) {
            resource.setProperty(propertyName, value);
            registry.put(resourcePath, resource);
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:21,代码来源:RegistryManager.java

示例11: persistTrustedService

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
private void persistTrustedService(String groupName, String serviceName, String trustedService,
                                   String certAlias) throws SecurityConfigException {
    Registry registry;
    String resourcePath;
    Resource resource;
    try {
        resourcePath = RegistryResources.SERVICE_GROUPS + groupName
                + RegistryResources.SERVICES + serviceName + "/trustedServices";
        registry = getConfigSystemRegistry(); //TODO: Multitenancy
        if (registry != null) {
            if (registry.resourceExists(resourcePath)) {
                resource = registry.get(resourcePath);
            } else {
                resource = registry.newResource();
            }
            if (resource.getProperty(trustedService) != null) {
                resource.removeProperty(trustedService);
            }
            resource.addProperty(trustedService, certAlias);
            registry.put(resourcePath, resource);
        }
    } catch (Exception e) {
        log.error("Error occured while adding trusted service for STS", e);
        throw new SecurityConfigException("Error occured while adding trusted service for STS",
                e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:STSAdminServiceImpl.java

示例12: createOrUpdate

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Create or update the OpenID admin.
 *
 * @param opAdmin openID admin
 * @throws IdentityException if error occurs while creating or updating the OpenID admin
 */
public void createOrUpdate(OpenIDAdminDO opAdmin) throws IdentityException {
    String path = null;
    Resource resource = null;

    try {
        path = IdentityRegistryResources.OPEN_ID_ADMIN_SETTINGS;
        if (!registry.resourceExists(path)) {
            if (log.isDebugEnabled()) {
                log.debug("Creating new openid admin");
            }
            resource = registry.newResource();
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Updating openid admin");
            }
            resource = registry.get(path);
            resource.removeProperty(IdentityRegistryResources.SUB_DOMAIN);
            resource.removeProperty(IdentityRegistryResources.OPENID_PATTERN);
        }
        resource.addProperty(IdentityRegistryResources.SUB_DOMAIN, opAdmin.getSubDomain());
        resource.addProperty(IdentityRegistryResources.OPENID_PATTERN, opAdmin
                .getTenantOpenIDPattern());
        registry.put(path, resource);
    } catch (RegistryException e) {
        log.error("Error while creating/updating openid admin", e);
        throw IdentityException.error("Error while creating/updating openid admin", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:35,代码来源:OpenIDAdminDAO.java

示例13: createOrUpdateParameter

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * @param parameterDO
 * @throws IdentityException
 */
public void createOrUpdateParameter(ParameterDO parameterDO) throws IdentityException {
    String path = null;
    Resource resource = null;

    if (log.isDebugEnabled()) {
        log.debug("Creating or updating parameter");
    }

    try {
        path = IdentityRegistryResources.CARD_ISSUER;
        if (registry.resourceExists(path)) {
            resource = registry.get(path);
        } else {
            resource = registry.newResource();
        }

        if (resource.getProperty(parameterDO.getName()) != null) {
            resource.removeProperty(parameterDO.getName());
        }

        resource.addProperty(parameterDO.getName(), parameterDO.getValue());
        registry.put(path, resource);
    } catch (RegistryException e) {
        log.error("Error while creating or updating parameter", e);
        throw IdentityException.error("Error while creating or updating parameter", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:32,代码来源:ParameterDAO.java

示例14: setChallengeQuestions

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * @param questionDTOs
 * @throws IdentityException
 */
public void setChallengeQuestions(ChallengeQuestionDTO[] questionDTOs) throws IdentityException {
    Registry registry = null;
    try {
        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        registry = IdentityMgtServiceComponent.getRegistryService().getConfigSystemRegistry(tenantId);

        if (!registry.resourceExists(IdentityMgtConstants.IDENTITY_MANAGEMENT_PATH)) {
            Collection securityQuestionResource = registry.newCollection();
            registry.put(IdentityMgtConstants.IDENTITY_MANAGEMENT_PATH, securityQuestionResource);
        }
        Resource identityMgtResource = registry.get(IdentityMgtConstants.IDENTITY_MANAGEMENT_PATH);
        if (identityMgtResource != null) {
            String questionCollectionPath = IdentityMgtConstants.IDENTITY_MANAGEMENT_QUESTIONS;
            if (registry.resourceExists(questionCollectionPath)) {
                registry.delete(questionCollectionPath);
            }

            Collection questionCollection = registry.newCollection();
            registry.put(questionCollectionPath, questionCollection);

            for (int i = 0; i < questionDTOs.length; i++) {
                Resource resource = registry.newResource();
                resource.addProperty("question", questionDTOs[i].getQuestion());
                resource.addProperty("isPromoteQuestion", String.valueOf(questionDTOs[i].isPromoteQuestion()));
                resource.addProperty("questionSetId", questionDTOs[i].getQuestionSetId());
                registry.put(IdentityMgtConstants.IDENTITY_MANAGEMENT_QUESTIONS +
                        RegistryConstants.PATH_SEPARATOR + "question" + i +
                        RegistryConstants.PATH_SEPARATOR, resource);
            }
        }
    } catch (RegistryException e) {
        throw IdentityException.error("Error while setting challenge question.", e);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:40,代码来源:ChallengeQuestionProcessor.java

示例15: testResourcePropertyVersioning

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testResourcePropertyVersioning() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("content 1");
        r1.addProperty("p1", "v1");
        registry.put("/v4/r1", r1);

        Resource r1v2 = registry.get("/v4/r1");
        r1v2.addProperty("p2", "v2");
        registry.put("/v4/r1", r1v2);
        registry.put("/v4/r1", r1v2);

        String[] r1Versions = registry.getVersions("/v4/r1");

        Resource r1vv1 = registry.get(r1Versions[1]);

        assertEquals("r1's first version should contain a property p1 with value v1",
                r1vv1.getProperty("p1"), "v1");

        Resource r1vv2 = registry.get(r1Versions[0]);

        assertEquals("r1's second version should contain a property p1 with value v1",
                r1vv2.getProperty("p1"), "v1");

        assertEquals("r1's second version should contain a property p2 with value v2",
                r1vv2.getProperty("p2"), "v2");
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:28,代码来源:VersionHandlingTest.java


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