Java Code Examples for org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO#setValue()

The following examples show how to use org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO#setValue() . 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: AbstractUserStoreDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
private UserStoreDTO getUserStoreProperty(UserStoreDTO userStoreDTO) throws IdentityUserStoreMgtException {

        boolean newState = userStoreDTO.getDisabled();
        UserStoreDTO userStoreDTOTemp = getUserStore(userStoreDTO.getDomainId());
        if (userStoreDTOTemp != null) {
            userStoreDTO = userStoreDTOTemp;
            userStoreDTO.setDisabled(newState);
            PropertyDTO[] propertyDTO = userStoreDTO.getProperties();
            for (PropertyDTO propertyDTOValue : propertyDTO) {
                if (propertyDTOValue.getName().equals(DISABLED)) {
                    propertyDTOValue.setValue(String.valueOf(newState));
                }
            }
        }
        return userStoreDTO;
    }
 
Example 2
Source File: ServerUserStoreService.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
/**
 * To handle the patch REPLACE request.
 *
 * @param domainId user store domain id.
 * @param path     patch operation path
 * @param value    property value
 * @return UserStoreResponse
 */
private UserStoreResponse performPatchReplace(String domainId, String path, String value) {

    UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance()
            .getUserStoreConfigService();
    try {
        UserStoreDTO userStoreDTO = userStoreConfigService.getUserStore(base64URLDecodeId(domainId));
        if (userStoreDTO == null) {
            throw handleException(Response.Status.NOT_FOUND, UserStoreConstants.ErrorMessage.ERROR_CODE_NOT_FOUND);
        }
        if (StringUtils.isBlank(path)) {
            throw handleException(Response.Status.BAD_REQUEST, UserStoreConstants.ErrorMessage
                    .ERROR_CODE_INVALID_INPUT);
        }
        PropertyDTO[] propertyDTOS = userStoreDTO.getProperties();
        if (path.startsWith(UserStoreConstants.USER_STORE_PROPERTIES)) {
            String[] propertiesList = path.split("/");
            for (PropertyDTO propertyDTO : propertyDTOS) {
                if (propertiesList[2].equals(propertyDTO.getName())) {
                    propertyDTO.setValue(value);
                }
            }
        } else if (path.equals(UserStoreConstants.USER_STORE_DESCRIPTION)) {
            userStoreDTO.setDescription(value);
        } else {
            throw handleException(Response.Status.BAD_REQUEST, UserStoreConstants.ErrorMessage
                    .ERROR_CODE_INVALID_INPUT);
        }
        userStoreDTO.setProperties(propertyDTOS);
        userStoreConfigService.updateUserStore(userStoreDTO, false);
        return buildResponseForPatchReplace(userStoreDTO, propertyDTOS);
    } catch (IdentityUserStoreMgtException e) {
        UserStoreConstants.ErrorMessage errorEnum =
                UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_USER_STORE;
        throw handleIdentityUserStoreMgtException(e, errorEnum);
    }
}
 
Example 3
Source File: ServerUserStoreService.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
/**
 * Construct PropertyDTO array for POST request.
 *
 * @param userStoreReq {@link UserStoreReq}.
 * @return PropertyDTO[].
 */
private PropertyDTO[] createPropertyListDTO(UserStoreReq userStoreReq) {

    List<org.wso2.carbon.identity.api.server.userstore.v1.model.Property> values = userStoreReq.getProperties();
    ArrayList<PropertyDTO> propertiesToAdd = new ArrayList<>();

    for (org.wso2.carbon.identity.api.server.userstore.v1.model.Property value : values) {
        PropertyDTO propertyDTO = new PropertyDTO();
        propertyDTO.setName(value.getName());
        propertyDTO.setValue(value.getValue());
        propertiesToAdd.add(propertyDTO);
    }
    return generatePropertiesWithUniqueIDProperty (propertiesToAdd);
}
 
Example 4
Source File: ServerUserStoreService.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
/**
 * Construct PropertyDTO array with UniqueID.
 *
 * @param propertiesToAdd Array list of properties.
 * @return PropertyDTO[].
 */
private PropertyDTO[] generatePropertiesWithUniqueIDProperty(ArrayList<PropertyDTO> propertiesToAdd) {

    PropertyDTO propertyDTO = new PropertyDTO();
    propertyDTO.setName("UniqueID");
    propertyDTO.setValue(UUID.randomUUID().toString());
    propertiesToAdd.add(propertyDTO);

    return propertiesToAdd.toArray(new PropertyDTO[0]);
}