diff --git a/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/vocabulary/UpdateVocabularyTermExecutor.java b/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/vocabulary/UpdateVocabularyTermExecutor.java index ce0e66536ed1054825e4b528228224ada132a88b..a4a4b8dca062efde02f4f2a98d5be027d7f6bb9a 100644 --- a/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/vocabulary/UpdateVocabularyTermExecutor.java +++ b/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/vocabulary/UpdateVocabularyTermExecutor.java @@ -155,11 +155,13 @@ public class UpdateVocabularyTermExecutor implements IUpdateVocabularyTermExecut if (termPE.isOfficial() && Boolean.FALSE.equals(update.isOfficial().getValue())) { throw new UserFailureException( - "Offical vocabulary term " + update.getVocabularyTermId() + " cannot be updated to be unofficial."); + "Official vocabulary term " + update.getVocabularyTermId() + " cannot be updated to be unofficial."); + } else if (!termPE.isOfficial() && Boolean.TRUE.equals(update.isOfficial().getValue())) + { + VocabularyTerm term = new VocabularyTerm(); + term.setId(termPE.getId()); + termBO.makeOfficial(Arrays.asList(term)); } - VocabularyTerm term = new VocabularyTerm(); - term.setId(termPE.getId()); - termBO.makeOfficial(Arrays.asList(term)); } } diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateVocabularyTermTest.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateVocabularyTermTest.java index 403b0637a008b137f42e4e57558f70b77cfb0985..97ad242f72ea48623a39fa3b2232c75d96da16e2 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateVocabularyTermTest.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateVocabularyTermTest.java @@ -91,6 +91,7 @@ public class UpdateVocabularyTermTest extends AbstractVocabularyTest VocabularyTermUpdate update = new VocabularyTermUpdate(); update.setVocabularyTermId(permIds.get(0)); + update.setDescription("updated description"); update.setOfficial(true); assertExceptionMessage(new IDelegatedAction() @@ -183,7 +184,7 @@ public class UpdateVocabularyTermTest extends AbstractVocabularyTest updateTerms(TEST_USER, PASSWORD, update); } - @Test(expectedExceptions = UserFailureException.class, expectedExceptionsMessageRegExp = ".*Offical vocabulary term DOG \\(ORGANISM\\) cannot be updated to be unofficial.*") + @Test(expectedExceptions = UserFailureException.class, expectedExceptionsMessageRegExp = ".*Official vocabulary term DOG \\(ORGANISM\\) cannot be updated to be unofficial.*") public void testUpdateWithOfficialTermMadeUnofficial() { VocabularyTermUpdate update = new VocabularyTermUpdate();