Search in sources :

Example 16 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationEndpointUtils method getResourceLinkList.

private static List<LinkDTO> getResourceLinkList(String resourceType, List<Resource> resources) {
    List<LinkDTO> linkDTOList = new ArrayList<>();
    for (Resource resource : resources) {
        LinkDTO linkDTO = new LinkDTO();
        linkDTO.setHref(getResourceURI(resourceType, resource));
        linkDTO.setRel("resource");
        linkDTOList.add(linkDTO);
    }
    return linkDTOList;
}
Also used : LinkDTO(org.wso2.carbon.identity.configuration.mgt.endpoint.dto.LinkDTO) ArrayList(java.util.ArrayList) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource)

Example 17 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationEndpointUtils method getResourceTypeDTO.

public static ResourceTypeDTO getResourceTypeDTO(ResourceType resourceType) throws ConfigurationManagementException {
    ResourceTypeDTO resourceTypeDTO = new ResourceTypeDTO();
    resourceTypeDTO.setName(resourceType.getName());
    resourceTypeDTO.setId(resourceType.getId());
    resourceTypeDTO.setDescription(resourceType.getDescription());
    resourceTypeDTO.setLinks(getResourceLinkList(resourceType.getName(), getConfigurationManager().getResourcesByType(resourceType.getName()).getResources()));
    return resourceTypeDTO;
}
Also used : ResourceTypeDTO(org.wso2.carbon.identity.configuration.mgt.endpoint.dto.ResourceTypeDTO)

Example 18 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationManagerImpl method getResourcesByType.

/**
 * {@inheritDoc}
 */
public Resources getResourcesByType(String resourceTypeName) throws ConfigurationManagementException {
    validateResourcesRetrieveRequest(resourceTypeName);
    ResourceType resourceType = getResourceType(resourceTypeName);
    List<Resource> resourceList = this.getConfigurationDAO().getResourcesByType(getTenantId(), resourceType.getId());
    if (resourceList == null) {
        if (log.isDebugEnabled()) {
            log.debug("No resource found for the resourceTypeName: " + resourceTypeName);
        }
        throw handleClientException(ErrorMessages.ERROR_CODE_RESOURCES_DOES_NOT_EXISTS, resourceTypeName, null);
    }
    return new Resources(resourceList);
}
Also used : Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) Resources(org.wso2.carbon.identity.configuration.mgt.core.model.Resources)

Example 19 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationManagerImpl method addResourceType.

/**
 * {@inheritDoc}
 */
public ResourceType addResourceType(ResourceTypeAdd resourceTypeAdd) throws ConfigurationManagementException {
    validateResourceTypeCreateRequest(resourceTypeAdd);
    String resourceTypeID = generateUniqueID();
    if (log.isDebugEnabled()) {
        log.debug("Resource type id generated: " + resourceTypeID);
    }
    ResourceType resourceType = generateResourceTypeFromRequest(resourceTypeAdd, resourceTypeID);
    getConfigurationDAO().addResourceType(resourceType);
    if (log.isDebugEnabled()) {
        log.debug("Resource type: " + resourceType.getName() + " successfully created with the id: " + resourceType.getId());
    }
    return new ResourceType(resourceType.getName(), resourceType.getId(), resourceType.getDescription());
}
Also used : ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType)

Example 20 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationManagerImpl method deleteResource.

/**
 * {@inheritDoc}
 */
public void deleteResource(String resourceTypeName, String resourceName) throws ConfigurationManagementException {
    validateResourceDeleteRequest(resourceTypeName, resourceName);
    ResourceType resourceType = getResourceType(resourceTypeName);
    this.getConfigurationDAO().deleteResourceByName(getTenantId(), resourceType.getId(), resourceName);
    if (log.isDebugEnabled()) {
        log.debug("Resource: " + resourceName + " is deleted successfully.");
    }
}
Also used : ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType)

Aggregations

ResourceType (org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType)36 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 Test (org.testng.annotations.Test)27 Resource (org.wso2.carbon.identity.configuration.mgt.core.model.Resource)22 Attribute (org.wso2.carbon.identity.configuration.mgt.core.model.Attribute)9 InputStream (java.io.InputStream)7 ResourceFile (org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 QName (javax.xml.namespace.QName)6 XMLStreamException (javax.xml.stream.XMLStreamException)6 OMAttribute (org.apache.axiom.om.OMAttribute)6 OMElement (org.apache.axiom.om.OMElement)6 Resources (org.wso2.carbon.identity.configuration.mgt.core.model.Resources)6 Resource (org.wso2.carbon.registry.core.Resource)6 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)6 File (java.io.File)5 APIProductResource (org.wso2.carbon.apimgt.api.model.APIProductResource)4 Mediation (org.wso2.carbon.apimgt.api.model.Mediation)4 JdbcTemplate (org.wso2.carbon.database.utils.jdbc.JdbcTemplate)4