Search in sources :

Example 1 with ClaimDialectResDTO

use of org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ClaimDialectResDTO in project identity-api-server by wso2.

the class ServerClaimManagementService method getClaimDialectResDTO.

private ClaimDialectResDTO getClaimDialectResDTO(ClaimDialect claimDialect) {
    ClaimDialectResDTO claimDialectResDTO = new ClaimDialectResDTO();
    String dialectId;
    if (StringUtils.equals(claimDialect.getClaimDialectURI(), LOCAL_DIALECT)) {
        dialectId = LOCAL_DIALECT_PATH;
    } else {
        dialectId = base64EncodeId(claimDialect.getClaimDialectURI());
    }
    claimDialectResDTO.setId(dialectId);
    claimDialectResDTO.setDialectURI(claimDialect.getClaimDialectURI());
    LinkDTO linkDTO = new LinkDTO();
    linkDTO.setRel(REL_CLAIMS);
    linkDTO.setHref(buildURIForBody(String.format(V1_API_PATH_COMPONENT + CMT_PATH_COMPONENT + "/%s/claims", dialectId)).toString());
    claimDialectResDTO.setLink(linkDTO);
    return claimDialectResDTO;
}
Also used : LinkDTO(org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.LinkDTO) ClaimDialectResDTO(org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ClaimDialectResDTO)

Example 2 with ClaimDialectResDTO

use of org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ClaimDialectResDTO in project identity-api-server by wso2.

the class ServerClaimManagementService method getClaimDialect.

/**
 * Retrieve a claim dialect.
 *
 * @param dialectId dialectId.
 * @return Claim dialect.
 */
public ClaimDialectResDTO getClaimDialect(String dialectId) {
    try {
        List<ClaimDialect> claimDialectList = getClaimMetadataManagementService().getClaimDialects(ContextLoader.getTenantDomainFromContext());
        String decodedDialectId;
        if (StringUtils.equals(dialectId, LOCAL_DIALECT_PATH)) {
            decodedDialectId = LOCAL_DIALECT;
        } else {
            decodedDialectId = base64DecodeId(dialectId);
        }
        ClaimDialect claimDialect = extractDialectFromDialectList(decodedDialectId, claimDialectList);
        if (claimDialect == null) {
            throw handleClaimManagementClientError(ERROR_CODE_DIALECT_NOT_FOUND, NOT_FOUND, dialectId);
        }
        return getClaimDialectResDTO(claimDialect);
    } catch (ClaimMetadataException e) {
        throw handleClaimManagementException(e, ERROR_CODE_ERROR_RETRIEVING_DIALECT, dialectId);
    }
}
Also used : ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) ClaimDialect(org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)

Aggregations

ClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException)1 ClaimDialect (org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)1 ClaimDialectResDTO (org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ClaimDialectResDTO)1 LinkDTO (org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.LinkDTO)1