Java Code Examples for org.wso2.carbon.registry.core.Resource#addProperty()

The following examples show how to use org.wso2.carbon.registry.core.Resource#addProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistryConfiguratorTestCase.java    From product-es with Apache License 2.0 6 votes vote down vote up
public void updateMimetypes() throws Exception {

        final String MIME_TYPE_PATH = "/_system/config/repository/components/org.wso2.carbon.governance" +
                "/media-types/index";
        WSRegistryServiceClient wsRegistry;
        RegistryProviderUtil registryProviderUtil = new RegistryProviderUtil();
        wsRegistry = registryProviderUtil.getWSRegistry(automationContext);
        Resource resource = wsRegistry.get(MIME_TYPE_PATH);
        resource.addProperty("properties", "text/properties");
        resource.addProperty("cfg", "text/config");
        resource.addProperty("rb", "text/ruby");
        resource.addProperty("drl", "xml/drool");
        resource.addProperty("xq", "xml/xquery");
        resource.addProperty("eva", "xml/evan");
        wsRegistry.put(MIME_TYPE_PATH, resource);

    }
 
Example 2
Source File: RegistryConfiguratorTestCase.java    From product-es with Apache License 2.0 6 votes vote down vote up
public void updateMimetypes() throws Exception {

        final String MIME_TYPE_PATH = "/_system/config/repository/components/org.wso2.carbon.governance" +
                "/media-types/index";
        WSRegistryServiceClient wsRegistry;
        RegistryProviderUtil registryProviderUtil = new RegistryProviderUtil();
        wsRegistry = registryProviderUtil.getWSRegistry(automationContext);
        Resource resource = wsRegistry.get(MIME_TYPE_PATH);
        resource.addProperty("properties", "text/properties");
        resource.addProperty("cfg", "text/config");
        resource.addProperty("rb", "text/ruby");
        resource.addProperty("drl", "xml/drool");
        resource.addProperty("xq", "xml/xquery");
        resource.addProperty("eva", "xml/evan");
        wsRegistry.put(MIME_TYPE_PATH, resource);

    }
 
Example 3
Source File: RegistryManager.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
	}
}
 
Example 4
Source File: RegistryManager.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * 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 addHostToRegistry(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.WEB_APP, 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;
	}
}
 
Example 5
Source File: ChallengeQuestionProcessor.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @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);
    }

}
 
Example 6
Source File: RegistryManager.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * @param host
 *            The virtual host to be stored in the registry
 * @param webApp
 *            The webapp to be deployed in the virtual host
 * @throws Exception
 */
public void updateHostToRegistry(Host host, String webApp) throws Exception {
	try {
		registryService.beginTransaction();
		Resource hostResource;
		String hostResourcePath = (UrlMapperConstants.HostProperties.HOSTINFO + host.getName());
		if (registryService.resourceExists(hostResourcePath)) {
			hostResource = registryService.get(hostResourcePath);
			hostResource.setProperty(UrlMapperConstants.HostProperties.HOST_NAME,
					host.getName());
			hostResource.setProperty(UrlMapperConstants.HostProperties.WEB_APP, webApp);
			registryService.put(UrlMapperConstants.HostProperties.HOSTINFO + host.getName(),
					hostResource);
		} else {
			hostResource = registryService.newResource();
			hostResource.addProperty(UrlMapperConstants.HostProperties.HOST_NAME,
					host.getName());
			hostResource.addProperty(UrlMapperConstants.HostProperties.WEB_APP, webApp);
			registryService.put(UrlMapperConstants.HostProperties.HOSTINFO + host.getName(),
					hostResource);
		}
		registryService.commitTransaction();

	} catch (Exception e) {
		registryService.rollbackTransaction();
		log.error("Unable to update the host", e);
		throw e;
	}
}
 
Example 7
Source File: GatewayUtils.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Add/Update the given registry property from the given tenant registry
 * path
 *
 * @param propertyName  property name
 * @param propertyValue property value
 * @param path          resource path
 * @param tenantDomain
 * @throws APIManagementException
 */
public static void setRegistryProperty(String propertyName, String propertyValue, String path, String tenantDomain)
        throws APIManagementException {

    UserRegistry registry = getRegistry(tenantDomain);
    PrivilegedCarbonContext.startTenantFlow();
    if (tenantDomain != null && StringUtils.isNotEmpty(tenantDomain)) {
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
    } else {
        PrivilegedCarbonContext.getThreadLocalCarbonContext()
                .setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
    }
    try {
        Resource resource = registry.get(path);
        // add or update property
        if (resource.getProperty(propertyName) != null) {
            resource.setProperty(propertyName, propertyValue);
        } else {
            resource.addProperty(propertyName, propertyValue);
        }
        registry.put(resource.getPath(), resource);
        resource.discard();
    } catch (RegistryException e) {
        throw new APIManagementException("Error while reading registry resource " + path + " for tenant " +
                tenantDomain);
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
Example 8
Source File: ParameterDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @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);
    }
}
 
Example 9
Source File: OpenIDAdminDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @param rp
 * @throws IdentityException
 */
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);
    }
}
 
Example 10
Source File: STSAdminServiceImpl.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 11
Source File: SecureVaultPasswordMigrationClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Method to update property
 *
 * @param name property name
 * @param value property value
 */
private void updateProperty(String name, String value) {
    log.info("Inserting new passwords.");
    try {
        Resource resource = userRegistry.get(SECURE_VAULT_PATH);
        resource.addProperty(name, value);
        userRegistry.put(resource.getPath(), resource);
        resource.discard();
    } catch (RegistryException e) {
        throw new MigrationClientException("Error occurred while updating property", e);
    }
}
 
Example 12
Source File: ChallengeQuestionProcessor.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * @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);
    }

}
 
Example 13
Source File: ParameterDAO.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * @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);
    }
}
 
Example 14
Source File: OpenIDAdminDAO.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 15
Source File: AbstractDAO.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * Returns all the objects in a given registry path with a given property values.
 *
 * @param path registry path
 * @param propName name of the property to be matched
 * @param value value of the property to be matched
 * @return list of all objects matching the given property value in the given registry path
 * @throws IdentityException if an error occurs while reading the registry
 */
public List<T> getAllObjectsWithPropertyValue(String path, String propName, String value)
        throws IdentityException {
    Resource query = null;
    List<T> retList = null;
    Map<String, String> params = null;
    Resource result = null;
    String[] paths = null;
    Resource resource = null;

    if (log.isErrorEnabled()) {
        log.debug("Retrieving all objects from the registry path with property values " + path);
    }

    try {
        retList = new ArrayList<T>();

        if (registry.resourceExists(CUSTOM_QUERY_GET_ALL_BY_PROP)) {
            //query = registry.get(CUSTOM_QUERY_GET_ALL_BY_PROP);
        } else {
            query = registry.newResource();
            query.setContent(SQL_GET_ALL_BY_PROP);
            query.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
            query.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
                    RegistryConstants.RESOURCES_RESULT_TYPE);
            registry.put(CUSTOM_QUERY_GET_ALL_BY_PROP, query);
        }

        params = new HashMap<String, String>();
        params.put("1", propName);
        params.put("2", value);
        result = registry.executeQuery(CUSTOM_QUERY_GET_ALL_BY_PROP, params);
        paths = (String[]) result.getContent();

        for (String prop : paths) {
            resource = registry.get(prop);
            retList.add(resourceToObject(resource));
        }
    } catch (RegistryException e) {
        String message = "Error while retrieving all objects from the registry path  with property values";
        log.error(message, e);
        throw IdentityException.error(message, e);
    }
    return retList;
}
 
Example 16
Source File: AbstractDAO.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
/**
 * @param path
 * @param propName
 * @param value
 * @return
 */
public List<T> getAllObjectsWithPropertyValue(String path, String propName, String value)
        throws IdentityException {
    Resource query = null;
    List<T> retList = null;
    Map<String, String> params = null;
    Resource result = null;
    String[] paths = null;
    Resource resource = null;

    if (log.isErrorEnabled()) {
        log.debug("Retreving all objects from the registry path with property values " + path);
    }

    try {
        retList = new ArrayList<T>();

        if (registry.resourceExists(CUSTOM_QUERY_GET_ALL_BY_PROP)) {
            //query = registry.get(CUSTOM_QUERY_GET_ALL_BY_PROP);
        } else {
            query = registry.newResource();
            query.setContent(SQL_GET_ALL_BY_PROP);
            query.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
            query.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
                    RegistryConstants.RESOURCES_RESULT_TYPE);
            registry.put(CUSTOM_QUERY_GET_ALL_BY_PROP, query);
        }

        params = new HashMap<String, String>();
        params.put("1", propName);
        params.put("2", value);
        result = registry.executeQuery(CUSTOM_QUERY_GET_ALL_BY_PROP, params);
        paths = (String[]) result.getContent();

        for (String prop : paths) {
            resource = registry.get(prop);
            retList.add(resourceToObject(resource));
        }
    } catch (RegistryException e) {
        String message = "Error while retreving all objects from the registry path  with property values";
        log.error(message, e);
        throw IdentityException.error(message, e);
    }
    return retList;
}
 
Example 17
Source File: RegistrySubscriptionManager.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void addSubscription(Subscription subscription) throws EventBrokerException {
    try {
        UserRegistry userRegistry =
                this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance()
                                                                         .getTenantId());
        String resourcePath =
                getResourcePath(subscription.getId(), subscription.getTopicName());

        Resource resource = userRegistry.newResource();
        resource.setProperty(EventBrokerConstants.EB_RES_SUBSCRIPTION_URL, subscription
                .getEventSinkURL());
        resource.setProperty(EventBrokerConstants.EB_RES_EVENT_DISPATCHER_NAME, subscription
                .getEventDispatcherName());

        if (subscription.getExpires() != null) {
            resource.setProperty(EventBrokerConstants.EB_RES_EXPIRS, ConverterUtil
                    .convertToString(subscription
                                             .getExpires()));
        }
        resource.setProperty(EventBrokerConstants.EB_RES_OWNER, subscription.getOwner());
        resource.setProperty(EventBrokerConstants.EB_RES_TOPIC_NAME, subscription
                .getTopicName());
        resource.setProperty(EventBrokerConstants.EB_RES_CREATED_TIME,
                             System.currentTimeMillis() + "");
        resource.setProperty(EventBrokerConstants.EB_RES_MODE, JavaUtil
                .getSubscriptionMode(subscription
                                             .getTopicName()));

        //set the other properties of the subscription.
        Map<String, String> properties = subscription.getProperties();
        for (String key : properties.keySet()) {
            resource.setProperty(key, properties.get(key));
        }

        userRegistry.put(resourcePath, resource);

        // add the subscription index
        String fullPath = this.indexStoragePath;
        Resource topicIndexResource;
        if (userRegistry.resourceExists(fullPath)) {
            topicIndexResource = userRegistry.get(fullPath);
            topicIndexResource.addProperty(subscription.getId(), subscription.getTopicName());
        } else {
            topicIndexResource = userRegistry.newResource();
            topicIndexResource.addProperty(subscription.getId(), subscription.getTopicName());
        }
        userRegistry.put(fullPath, topicIndexResource);

    } catch (RegistryException e) {
        throw new EventBrokerException("Cannot save to registry ", e);
    }

}
 
Example 18
Source File: MetadataApiRegistry.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
public void addPropertyToApplication(String applicationId, Property property)
        throws RegistryException, MetadataException {
    Registry registry = getRegistry();
    String resourcePath = mainResource + applicationId;

    try {
        acquireWriteLock(applicationId);
        // We are using only super tenant registry to persist
        PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        Resource nodeResource;
        if (registry.resourceExists(resourcePath)) {
            nodeResource = registry.get(resourcePath);
        } else {
            nodeResource = registry.newCollection();
            if (log.isDebugEnabled()) {
                log.debug(String.format("Registry resource created: [resource-path] %s", resourcePath));
            }
        }

        boolean updated = false;
        for (String value : property.getValues()) {
            if (!propertyValueExist(nodeResource, property.getKey(), value)) {
                updated = true;
                if (log.isDebugEnabled()) {
                    log.debug(String.format("Registry property updated: [resource-path] %s, [key] %s [value] %s",
                            resourcePath, property.getKey(), value));
                }
                nodeResource.addProperty(property.getKey(), value);
            } else {
                if (log.isDebugEnabled()) {
                    log.debug(
                            String.format("Registry value already exists: [resource-path] %s, [key] %s, [value] %s",
                                    resourcePath, property.getKey(), value));
                }
            }
        }
        if (updated) {
            registry.put(resourcePath, nodeResource);
            if (log.isDebugEnabled()) {
                log.debug(String.format("Registry property is persisted: [resource-path] %s, [key] %s, [values] %s",
                        resourcePath, property.getKey(), Arrays.asList(property.getValues())));
            }
        }
    } catch (Exception e) {
        String msg = String
                .format("Failed to persist properties in registry: [resource-path] %s, [key] %s, [values] %s",
                        resourcePath, property.getKey(), Arrays.asList(property.getValues()));
        log.error(msg, e);
        throw new MetadataException(msg, e);
    } finally {
        try {
            releaseWriteLock(applicationId);
        } catch (MetadataException ignored) {
        }
    }
}