mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
#83: Tag name duplicates now allowed
This commit is contained in:
parent
27027ec412
commit
c398a3c4f5
9
.travis.yml
Normal file
9
.travis.yml
Normal file
@ -0,0 +1,9 @@
|
||||
language: java
|
||||
before_install:
|
||||
- sudo apt-get -qq update
|
||||
- sudo apt-get -y -q install tesseract-ocr tesseract-ocr-fra tesseract-ocr-jpn
|
||||
env:
|
||||
- TESSDATA_PREFIX=/usr/share/tesseract-ocr
|
||||
- LC_NUMERIC=C
|
||||
before_script:
|
||||
- cd docs-parent
|
@ -57,7 +57,7 @@ public class TagResource extends BaseResource {
|
||||
.add("id", tagDto.getId())
|
||||
.add("name", tagDto.getName())
|
||||
.add("color", tagDto.getColor())
|
||||
.add("parent", JsonUtil.nullable(tagDto.getParentId())));
|
||||
.add("parent", JsonUtil.nullable(tagDto.getParentId()))); // TODO Don't return the parent if it's not visible
|
||||
}
|
||||
|
||||
JsonObjectBuilder response = Json.createObjectBuilder()
|
||||
@ -120,18 +120,12 @@ public class TagResource extends BaseResource {
|
||||
throw new ClientException("SpacesNotAllowed", "Spaces are not allowed in tag name");
|
||||
}
|
||||
|
||||
// Get the tag
|
||||
TagDao tagDao = new TagDao();
|
||||
List<TagDto> tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setName(name), null);
|
||||
if (tagDtoList.size() > 0) {
|
||||
throw new ClientException("AlreadyExistingTag", MessageFormat.format("Tag already exists: {0}", name));
|
||||
}
|
||||
|
||||
// Check the parent
|
||||
TagDao tagDao = new TagDao();
|
||||
if (StringUtils.isEmpty(parentId)) {
|
||||
parentId = null;
|
||||
} else {
|
||||
tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setId(parentId), null);
|
||||
List<TagDto> tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setId(parentId), null);
|
||||
if (tagDtoList.size() == 0) {
|
||||
throw new ClientException("ParentNotFound", MessageFormat.format("Parent not found: {0}", parentId));
|
||||
}
|
||||
@ -212,12 +206,6 @@ public class TagResource extends BaseResource {
|
||||
parentId = tagDtoList.get(0).getId();
|
||||
}
|
||||
|
||||
// Check for name duplicate
|
||||
tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setName(name), null);
|
||||
if (tagDtoList.size() > 0 && !tagDtoList.get(0).getId().equals(id)) {
|
||||
throw new ClientException("AlreadyExistingTag", MessageFormat.format("Tag already exists: {0}", name));
|
||||
}
|
||||
|
||||
// Update the tag
|
||||
Tag tag = tagDao.getById(id);
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
|
@ -55,7 +55,7 @@ public class TestTagResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(Status.BAD_REQUEST, Status.fromStatusCode(response.getStatus()));
|
||||
|
||||
// Create a document
|
||||
json = target().path("/document").request()
|
||||
target().path("/document").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, tag1Token)
|
||||
.put(Entity.form(new Form()
|
||||
.param("title", "My super document 1")
|
||||
|
Loading…
Reference in New Issue
Block a user