use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project charon by wso2.
the class AbstractSCIMObject method setResourceType.
/**
* set the resourceType of the meta attribute
*
* @param resourceType
*/
public void setResourceType(String resourceType) throws BadRequestException, CharonException {
// create the resourceType attribute as defined in schema.
SimpleAttribute resourceTypeAttribute = (SimpleAttribute) DefaultAttributeFactory.createAttribute(SCIMSchemaDefinitions.RESOURCE_TYPE, new SimpleAttribute(SCIMConstants.CommonSchemaConstants.RESOURCE_TYPE, resourceType));
// check meta complex attribute already exist.
if (getMetaAttribute() != null) {
ComplexAttribute metaAttribute = getMetaAttribute();
// check version attribute already exist
if (metaAttribute.isSubAttributeExist(resourceTypeAttribute.getName())) {
String error = "Read only attribute is tried to modify";
throw new CharonException(error);
} else {
metaAttribute.setSubAttribute(resourceTypeAttribute);
}
} else {
// create meta attribute and set the sub attribute.
createMetaAttribute();
getMetaAttribute().setSubAttribute(resourceTypeAttribute);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project charon by wso2.
the class ScimAttributeAware method replaceResourceType.
/**
* sets or overrides the resource type attribute of the given {@link #getResource()} object
*
* @param resourceType the resource type attribute to write
*/
public void replaceResourceType(String resourceType) {
SCIMAttributeSchema metaDefinition = SCIMSchemaDefinitions.META;
SCIMAttributeSchema resourceTypeDefinition = SCIMSchemaDefinitions.RESOURCE_TYPE;
ComplexAttribute meta = getOrCrateComplexAttribute(metaDefinition);
getSetSubAttributeConsumer(meta).accept(resourceTypeDefinition, () -> resourceType);
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.
the class ConfigurationManagerTest method testReplaceNonExistingAttribute.
@Test(priority = 19)
public void testReplaceNonExistingAttribute() throws Exception {
ResourceType resourceType = configurationManager.addResourceType(getSampleResourceTypeAdd());
Resource resource = configurationManager.addResource(resourceType.getName(), getSampleResource1Add());
Attribute attribute = getSampleAttribute3();
Attribute retrievedAttribute = configurationManager.replaceAttribute(resourceType.getName(), resource.getResourceName(), attribute);
assertNotNull(retrievedAttribute.getAttributeId(), "Created resource id cannot be null");
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.
the class ConfigurationManagerTest method testAddResource.
@Test(priority = 9)
public void testAddResource() throws Exception {
ResourceType resourceType = configurationManager.addResourceType(getSampleResourceTypeAdd());
ResourceAdd resourceTypeAdd = getSampleResource1Add();
Resource resource = configurationManager.addResource(resourceType.getName(), resourceTypeAdd);
assertNotNull(resource.getResourceId(), "Created resource type id cannot be null");
}
use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.
the class ConfigurationManagerTest method testGetResourcesByType.
@Test(priority = 31)
public void testGetResourcesByType() throws Exception {
ResourceType resourceType = configurationManager.addResourceType(getSampleResourceType2Add());
Resource resource1 = configurationManager.addResource(resourceType.getName(), getSampleResource1Add());
Resource resource2 = configurationManager.addResource(resourceType.getName(), getSampleResource2Add());
Resources resourcesByType = configurationManager.getResourcesByType(resourceType.getName());
Assert.assertTrue("Retrieved resource count should be equal to the added value", resourcesByType.getResources().size() == 2);
Assert.assertEquals("Created resource name should be equal to the retrieved resource name", resource1.getResourceName(), resourcesByType.getResources().get(0).getResourceName());
Assert.assertEquals("Created resource name should be equal to the retrieved resource name", resource2.getResourceName(), resourcesByType.getResources().get(1).getResourceName());
}
Aggregations