From 90ad5bf4f1d77eefebfbb0a75bcc31c6996e44ec Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Thu, 7 Jan 2016 16:03:19 +0100 Subject: [PATCH] CL-431: enhance repository entry API for location --- .../java/org/olat/repository/RepositoryManager.java | 6 +++++- .../restapi/repository/RepositoryEntryResource.java | 10 ++++++---- .../reminder/manager/ReminderRuleEngineTest.java | 4 ++-- .../org/olat/repository/RepositoryManagerTest.java | 4 +++- .../repository/manager/RepositoryEntryDAOTest.java | 2 +- .../manager/RepositoryEntryStatisticsDAOTest.java | 4 ++-- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/olat/repository/RepositoryManager.java b/src/main/java/org/olat/repository/RepositoryManager.java index ddf08e477f1..3e7b54785f7 100644 --- a/src/main/java/org/olat/repository/RepositoryManager.java +++ b/src/main/java/org/olat/repository/RepositoryManager.java @@ -681,7 +681,8 @@ public class RepositoryManager extends BasicManager { * @return */ public RepositoryEntry setDescriptionAndName(final RepositoryEntry re, String displayName, String description, - String authors, String externalId, String externalRef, String managedFlags, RepositoryEntryLifecycle cycle) { + String location, String authors, String externalId, String externalRef, String managedFlags, + RepositoryEntryLifecycle cycle) { RepositoryEntry reloadedRe = loadForUpdate(re); if(StringHelper.containsNonWhitespace(displayName)) { reloadedRe.setDisplayname(displayName); @@ -692,6 +693,9 @@ public class RepositoryManager extends BasicManager { if(StringHelper.containsNonWhitespace(authors)) { reloadedRe.setAuthors(authors); } + if(StringHelper.containsNonWhitespace(location)) { + reloadedRe.setLocation(location); + } if(StringHelper.containsNonWhitespace(externalId)) { reloadedRe.setExternalId(externalId); } diff --git a/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java b/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java index f23e2a1acf6..8e70cda26e4 100644 --- a/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java +++ b/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java @@ -620,8 +620,9 @@ public class RepositoryEntryResource { } } - RepositoryEntry reloaded = repositoryManager.setDescriptionAndName(re, vo.getDisplayname(), null, - vo.getAuthors(), vo.getExternalId(), vo.getExternalRef(), vo.getManagedFlags(), lifecycle); + RepositoryEntry reloaded = repositoryManager.setDescriptionAndName(re, vo.getDisplayname(), null, + vo.getLocation(), vo.getAuthors(), vo.getExternalId(), vo.getExternalRef(), vo.getManagedFlags(), + lifecycle); RepositoryEntryVO rvo = ObjectFactory.get(reloaded); return Response.ok(rvo).build(); } @@ -662,6 +663,7 @@ public class RepositoryEntryResource { reader = new MultipartReader(request); File tmpFile = reader.getFile(); String displayname = reader.getValue("displayname"); + String location = reader.getValue("location"); String authors = reader.getValue("authors"); String description = reader.getValue("description"); String externalId = reader.getValue("externalId"); @@ -672,7 +674,7 @@ public class RepositoryEntryResource { RepositoryEntry replacedRe; if(tmpFile == null) { replacedRe = repositoryManager.setDescriptionAndName(re, displayname, description, - authors, externalId, externalRef, managedFlags, re.getLifecycle()); + location, authors, externalId, externalRef, managedFlags, re.getLifecycle()); } else { long length = tmpFile.length(); if(length == 0) { @@ -683,7 +685,7 @@ public class RepositoryEntryResource { return Response.serverError().status(Status.NOT_FOUND).build(); } else { replacedRe = repositoryManager.setDescriptionAndName(replacedRe, displayname, description, - authors, externalId, externalRef, managedFlags, replacedRe.getLifecycle()); + location, authors, externalId, externalRef, managedFlags, replacedRe.getLifecycle()); } } RepositoryEntryVO vo = ObjectFactory.get(replacedRe); diff --git a/src/test/java/org/olat/modules/reminder/manager/ReminderRuleEngineTest.java b/src/test/java/org/olat/modules/reminder/manager/ReminderRuleEngineTest.java index 5f42de371da..5cb8e7fb644 100644 --- a/src/test/java/org/olat/modules/reminder/manager/ReminderRuleEngineTest.java +++ b/src/test/java/org/olat/modules/reminder/manager/ReminderRuleEngineTest.java @@ -679,7 +679,7 @@ public class ReminderRuleEngineTest extends OlatTestCase { Date validTo = cal.getTime(); RepositoryEntryLifecycle cycle = lifecycleDao.create("Cycle 1", "Cycle soft 1", false, validFrom, validTo); - re = repositoryManager.setDescriptionAndName(re, null, null, null, null, null, null, cycle); + re = repositoryManager.setDescriptionAndName(re, null, null, null, null, null, null, null, cycle); repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name()); repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name()); repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name()); @@ -764,7 +764,7 @@ public class ReminderRuleEngineTest extends OlatTestCase { Date validTo = cal.getTime(); RepositoryEntryLifecycle cycle = lifecycleDao.create("Cycle 2", "Cycle soft 2", false, validFrom, validTo); - re = repositoryManager.setDescriptionAndName(re, null, null, null, null, null, null, cycle); + re = repositoryManager.setDescriptionAndName(re, null, null, null, null, null, null, null, cycle); repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name()); repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name()); repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name()); diff --git a/src/test/java/org/olat/repository/RepositoryManagerTest.java b/src/test/java/org/olat/repository/RepositoryManagerTest.java index ac3f65b53a5..6e39d530c89 100644 --- a/src/test/java/org/olat/repository/RepositoryManagerTest.java +++ b/src/test/java/org/olat/repository/RepositoryManagerTest.java @@ -1161,6 +1161,7 @@ public class RepositoryManagerTest extends OlatTestCase { String newName = "Brand new name"; String newDesc = "Brand new description"; String newAuthors = "Me and only me"; + String newLocation = "Far away"; String newExternalId = "Brand - ext"; String newExternalRef = "Brand - ref"; String newManagedFlags = RepositoryEntryManagedFlag.access.name(); @@ -1168,7 +1169,7 @@ public class RepositoryManagerTest extends OlatTestCase { RepositoryEntryLifecycle newCycle = lifecycleDao.create("New cycle 1", "New cycle soft 1", false, new Date(), new Date()); - re = repositoryManager.setDescriptionAndName(re, newName, newDesc, newAuthors, newExternalId, newExternalRef, newManagedFlags, newCycle); + re = repositoryManager.setDescriptionAndName(re, newName, newDesc, newLocation, newAuthors, newExternalId, newExternalRef, newManagedFlags, newCycle); Assert.assertNotNull(re); dbInstance.commitAndCloseSession(); @@ -1176,6 +1177,7 @@ public class RepositoryManagerTest extends OlatTestCase { RepositoryEntry reloaded = repositoryManager.lookupRepositoryEntry(re.getKey()); Assert.assertNotNull(reloaded); Assert.assertEquals("Me and only me", reloaded.getAuthors()); + Assert.assertEquals("Far away", reloaded.getLocation()); Assert.assertEquals("Brand new name", reloaded.getDisplayname()); Assert.assertEquals("Brand new description", reloaded.getDescription()); Assert.assertEquals("Brand - ext", reloaded.getExternalId()); diff --git a/src/test/java/org/olat/repository/manager/RepositoryEntryDAOTest.java b/src/test/java/org/olat/repository/manager/RepositoryEntryDAOTest.java index 6a63de0e140..0bda248053f 100644 --- a/src/test/java/org/olat/repository/manager/RepositoryEntryDAOTest.java +++ b/src/test/java/org/olat/repository/manager/RepositoryEntryDAOTest.java @@ -102,7 +102,7 @@ public class RepositoryEntryDAOTest extends OlatTestCase { dbInstance.commit(); String externalId = UUID.randomUUID().toString(); String externalRef = UUID.randomUUID().toString(); - re = repositoryManager.setDescriptionAndName(re, null, null, null, externalId, externalRef, null, null); + re = repositoryManager.setDescriptionAndName(re, null, null, null, null, externalId, externalRef, null, null); dbInstance.commitAndCloseSession(); //by primary key diff --git a/src/test/java/org/olat/repository/manager/RepositoryEntryStatisticsDAOTest.java b/src/test/java/org/olat/repository/manager/RepositoryEntryStatisticsDAOTest.java index 52c1b834230..3873b783ab8 100644 --- a/src/test/java/org/olat/repository/manager/RepositoryEntryStatisticsDAOTest.java +++ b/src/test/java/org/olat/repository/manager/RepositoryEntryStatisticsDAOTest.java @@ -170,7 +170,7 @@ public class RepositoryEntryStatisticsDAOTest extends OlatTestCase { String description = "Description_testIncrementLaunchCounterSetDescription"; log.info("RepositoryManagerTest: call setDescriptionAndName"); long t3 = System.nanoTime(); - repositoryManager.setDescriptionAndName(repositoryEntryT1, displayName, description, null, null, null, null, null); + repositoryManager.setDescriptionAndName(repositoryEntryT1, displayName, description, null, null, null, null, null, null); long t4 = System.nanoTime(); log.info("RepositoryManagerTest: call setDescriptionAndName DONE"); log.info("RepositoryManagerTest: increments take=" + (t2 - t1) + " setDescription take=" + (t4 -t3) ); @@ -271,7 +271,7 @@ public class RepositoryEntryStatisticsDAOTest extends OlatTestCase { if (i % 25 == 0 ) { String displayName = "DisplayName" + i; String description = "Description" + i; - re = repositoryManager.setDescriptionAndName(re, displayName, description, null, null, null, null, null); + re = repositoryManager.setDescriptionAndName(re, displayName, description, null, null, null, null, null, null); assertEquals("Wrong displayName value", displayName, re.getDisplayname()); assertEquals("Wrong description value", description, re.getDescription()); } -- GitLab