/// <summary> /// Checks the id of the given resource and changes to a unique identifier if it /// isn't one already. /// </summary> /// <param name="resource">resource</param> public void fixResourceId(Resource resource) { string resourceId = resource.getId(); if (StringUtil.isBlank(resource.getId())) { resourceId = StringUtil.substringBeforeLast(resource.getHref(), '.'); resourceId = StringUtil.substringAfterLast(resourceId, '/'); } resourceId = makeValidId(resourceId, resource); // check if the id is unique. if not: create one from scratch if (StringUtil.isBlank(resourceId) || containsId(resourceId)) { resourceId = createUniqueResourceId(resource); } resource.setId(resourceId); }
/// <summary> /// Checks the id of the given resource and changes to a unique identifier if it /// isn't one already. /// </summary> /// <param name="resource">resource</param> public void fixResourceId(Resource resource) { string resourceId = resource.getId(); if (StringUtil.isBlank(resource.getId())) { resourceId = StringUtil.substringBeforeLast(resource.getHref(), '.'); resourceId = StringUtil.substringAfterLast(resourceId, '/'); } resourceId = makeValidId(resourceId, resource); // check if the id is unique. if not: create one from scratch if (StringUtil.isBlank(resourceId) || containsId(resourceId)) { resourceId = createUniqueResourceId(resource); } resource.setId(resourceId); }