diff --git a/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java b/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java index 8e70cda26e44cee04d2c8a34798e2339e79f2e04..be2c9388d668e1afa725dc2c640809d81911f4e6 100644 --- a/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java +++ b/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java @@ -620,7 +620,7 @@ public class RepositoryEntryResource { } } - RepositoryEntry reloaded = repositoryManager.setDescriptionAndName(re, vo.getDisplayname(), null, + RepositoryEntry reloaded = repositoryManager.setDescriptionAndName(re, vo.getDisplayname(), vo.getDescription(), vo.getLocation(), vo.getAuthors(), vo.getExternalId(), vo.getExternalRef(), vo.getManagedFlags(), lifecycle); RepositoryEntryVO rvo = ObjectFactory.get(reloaded); diff --git a/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java b/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java index b94462ac8929843d3e9c6e0b979dc2db5b1748c1..61d586c61f1176abad6601c28b2728cfc3a1b1a6 100644 --- a/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java +++ b/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java @@ -225,8 +225,8 @@ public class CoursesWebService { @PUT @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response createEmptyCourse(@QueryParam("shortTitle") String shortTitle, @QueryParam("title") String title, - @QueryParam("displayName") String displayName, @QueryParam("softKey") String softKey, - @QueryParam("access") Integer access, @QueryParam("membersOnly") Boolean membersOnly, + @QueryParam("displayName") String displayName, @QueryParam("description") String description, + @QueryParam("softKey") String softKey, @QueryParam("access") Integer access, @QueryParam("membersOnly") Boolean membersOnly, @QueryParam("externalId") String externalId, @QueryParam("externalRef") String externalRef, @QueryParam("authors") String authors, @QueryParam("location") String location, @QueryParam("managedFlags") String managedFlags, @QueryParam("sharedFolderSoftKey") String sharedFolderSoftKey, @@ -256,9 +256,9 @@ public class CoursesWebService { } } if(copyFrom != null) { - course = copyCourse(copyFrom, ureq, id, shortTitle, title, displayName, softKey, accessInt, membersOnlyBool, authors, location, externalId, externalRef, managedFlags, configVO); + course = copyCourse(copyFrom, ureq, id, shortTitle, title, displayName, description, softKey, accessInt, membersOnlyBool, authors, location, externalId, externalRef, managedFlags, configVO); } else { - course = createEmptyCourse(id, shortTitle, title, displayName, softKey, accessInt, membersOnlyBool, authors, location, externalId, externalRef, managedFlags, configVO); + course = createEmptyCourse(id, shortTitle, title, displayName, description, softKey, accessInt, membersOnlyBool, authors, location, externalId, externalRef, managedFlags, configVO); } if(course == null) { return Response.serverError().status(Status.NOT_FOUND).build(); @@ -290,7 +290,7 @@ public class CoursesWebService { CourseConfigVO configVO = new CourseConfigVO(); ICourse course = createEmptyCourse(ureq.getIdentity(), - courseVo.getTitle(), courseVo.getTitle(), courseVo.getTitle(), + courseVo.getTitle(), courseVo.getTitle(), courseVo.getTitle(), courseVo.getDescription(), courseVo.getSoftKey(), RepositoryEntry.ACC_OWNERS, false, courseVo.getAuthors(), courseVo.getLocation(), courseVo.getExternalId(), courseVo.getExternalRef(), courseVo.getManagedFlags(), @@ -401,7 +401,7 @@ public class CoursesWebService { } private static ICourse copyCourse(Long copyFrom, UserRequest ureq, Identity initialAuthor, String shortTitle, String longTitle, String displayName, - String softKey, int access, boolean membersOnly, String authors, String location, String externalId, String externalRef, + String description, String softKey, int access, boolean membersOnly, String authors, String location, String externalId, String externalRef, String managedFlags, CourseConfigVO courseConfigVO) { //String learningObjectives = name + " (Example of creating a new course)"; @@ -428,7 +428,10 @@ public class CoursesWebService { //create new repo entry String name; - String description = src.getDescription(); + if(description == null || description.trim().length() == 0) { + description = src.getDescription(); + } + if (courseConfigVO != null && StringHelper.containsNonWhitespace(displayName)) { name = displayName; } else { @@ -497,7 +500,7 @@ public class CoursesWebService { * @return */ public static ICourse createEmptyCourse(Identity initialAuthor, String shortTitle, String longTitle, CourseConfigVO courseConfigVO) { - return createEmptyCourse(initialAuthor, shortTitle, longTitle, shortTitle, null, RepositoryEntry.ACC_OWNERS, false, null, null, null, null, null, courseConfigVO); + return createEmptyCourse(initialAuthor, shortTitle, longTitle, shortTitle, null, null, RepositoryEntry.ACC_OWNERS, false, null, null, null, null, null, courseConfigVO); } /** @@ -513,7 +516,7 @@ public class CoursesWebService { * @return */ public static ICourse createEmptyCourse(Identity initialAuthor, String shortTitle, String longTitle, String reDisplayName, - String softKey, int access, boolean membersOnly, String authors, String location, + String description, String softKey, int access, boolean membersOnly, String authors, String location, String externalId, String externalRef, String managedFlags, CourseConfigVO courseConfigVO) { String learningObjectives = shortTitle + " (Example of creating a new course)"; @@ -534,6 +537,7 @@ public class CoursesWebService { addedEntry.setExternalId(externalId); addedEntry.setExternalRef(externalRef); addedEntry.setManagedFlagsString(managedFlags); + addedEntry.setDescription(description); if(RepositoryEntryManagedFlag.isManaged(addedEntry, RepositoryEntryManagedFlag.membersmanagement)) { addedEntry.setAllowToLeaveOption(RepositoryEntryAllowToLeaveOptions.never); } else { diff --git a/src/main/java/org/olat/restapi/support/ObjectFactory.java b/src/main/java/org/olat/restapi/support/ObjectFactory.java index ee33fc04e21c8058404a959368d65944c5f601b1..13a7ea85ee60d3989ef2fe6dee1503acd4504981 100644 --- a/src/main/java/org/olat/restapi/support/ObjectFactory.java +++ b/src/main/java/org/olat/restapi/support/ObjectFactory.java @@ -158,6 +158,7 @@ public class ObjectFactory { vo.setSoftkey(entry.getSoftkey()); vo.setResourcename(entry.getResourcename()); vo.setDisplayname(entry.getDisplayname()); + vo.setDescription(entry.getDescription()); vo.setAuthors(entry.getAuthors()); vo.setLocation(entry.getLocation()); vo.setResourceableId(entry.getResourceableId()); @@ -187,6 +188,7 @@ public class ObjectFactory { CourseVO vo = new CourseVO(); vo.setKey(course.getResourceableId()); vo.setDisplayName(re.getDisplayname()); + vo.setDescription(re.getDescription()); vo.setTitle(course.getCourseTitle()); vo.setEditorRootNodeId(course.getEditorTreeModel().getRootNode().getIdent()); vo.setSoftKey(re.getSoftkey()); diff --git a/src/main/java/org/olat/restapi/support/vo/CourseVO.java b/src/main/java/org/olat/restapi/support/vo/CourseVO.java index 426f68f246ae8eb988f0aa9981a75ecd6c21dc60..8d714f0f16c139fde52047471498ae88f1fd8463 100644 --- a/src/main/java/org/olat/restapi/support/vo/CourseVO.java +++ b/src/main/java/org/olat/restapi/support/vo/CourseVO.java @@ -40,6 +40,7 @@ public class CourseVO { private Long key; private String softKey; private String displayName; + private String description; private Long repoEntryKey; @XmlAttribute(name="authors",required=false) private String authors; @@ -166,6 +167,14 @@ public class CourseVO { this.displayName = displayName; } + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + public String getEditorRootNodeId() { return editorRootNodeId; } diff --git a/src/main/java/org/olat/restapi/support/vo/RepositoryEntryVO.java b/src/main/java/org/olat/restapi/support/vo/RepositoryEntryVO.java index f78973062dc16786753f9d0bc71c1469ce33779b..4da2afc50be2e51822f8c01fdabbb657bdc5702b 100644 --- a/src/main/java/org/olat/restapi/support/vo/RepositoryEntryVO.java +++ b/src/main/java/org/olat/restapi/support/vo/RepositoryEntryVO.java @@ -41,6 +41,7 @@ public class RepositoryEntryVO { private String softkey; private String resourcename; private String displayname; + private String description; @XmlAttribute(name="authors",required=false) private String authors; @XmlAttribute(name="location",required=false) @@ -93,6 +94,14 @@ public class RepositoryEntryVO { this.displayname = displayname; } + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + public String getAuthors() { return authors; } diff --git a/src/test/java/org/olat/restapi/CoursesTest.java b/src/test/java/org/olat/restapi/CoursesTest.java index 1576b5a4abad802b71ba3ff597f08375f0e402fb..3d9c19393a0646304870eaab514a9f89c282dfe7 100644 --- a/src/test/java/org/olat/restapi/CoursesTest.java +++ b/src/test/java/org/olat/restapi/CoursesTest.java @@ -111,11 +111,11 @@ public class CoursesTest extends OlatJerseyTestCase { try { // create course and persist as OLATResourceImpl admin = BaseSecurityManager.getInstance().findIdentityByName("administrator"); - course1 = CoursesWebService.createEmptyCourse(admin, "courses1", "courses1 long name", null, null, RepositoryEntry.ACC_OWNERS, false, null, null, null, null, null, null); + course1 = CoursesWebService.createEmptyCourse(admin, "courses1", "courses1 long name", null, null, null, RepositoryEntry.ACC_OWNERS, false, null, null, null, null, null, null); externalId = UUID.randomUUID().toString(); externalRef = UUID.randomUUID().toString(); - course2 = CoursesWebService.createEmptyCourse(admin, "courses2", "courses2 long name", null, null, RepositoryEntry.ACC_OWNERS, false, null, null, externalId, externalRef, "all", null); + course2 = CoursesWebService.createEmptyCourse(admin, "courses2", "courses2 long name", null, null, null, RepositoryEntry.ACC_OWNERS, false, null, null, externalId, externalRef, "all", null); dbInstance.commitAndCloseSession(); @@ -123,7 +123,7 @@ public class CoursesTest extends OlatJerseyTestCase { re2 = repositoryManager.lookupRepositoryEntry(course2, false); externalId3 = UUID.randomUUID().toString(); - course3 = CoursesWebService.createEmptyCourse(admin, "courses3", "courses3 long name", null, null, RepositoryEntry.ACC_OWNERS, false, null, null, externalId3, null, "all", null); + course3 = CoursesWebService.createEmptyCourse(admin, "courses3", "courses3 long name", null, null, null, RepositoryEntry.ACC_OWNERS, false, null, null, externalId3, null, "all", null); re3 = repositoryManager.lookupRepositoryEntry(course3, false); RepositoryEntryLifecycle lifecycle3 = reLifecycleDao.create("course3 lifecycle", UUID.randomUUID().toString(), true, new Date(), new Date()); dbInstance.commit(); diff --git a/src/test/java/org/olat/restapi/EfficiencyStatementTest.java b/src/test/java/org/olat/restapi/EfficiencyStatementTest.java index 0fab7ad3b1ca0e46fd9b7773d5cdafffcfaa592c..0a5040a89b5df9fd211d22ba425d26c5800f8599 100644 --- a/src/test/java/org/olat/restapi/EfficiencyStatementTest.java +++ b/src/test/java/org/olat/restapi/EfficiencyStatementTest.java @@ -67,7 +67,7 @@ public class EfficiencyStatementTest extends OlatJerseyTestCase { // create a standalone efficiency statement Identity admin = BaseSecurityManager.getInstance().findIdentityByName("administrator"); Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("eff-1"); - ICourse course = CoursesWebService.createEmptyCourse(admin, "courses1", "courses1 long name", null, null, RepositoryEntry.ACC_OWNERS, false, null, null, null, null, null, null); + ICourse course = CoursesWebService.createEmptyCourse(admin, "courses1", "courses1 long name", null, null, null, RepositoryEntry.ACC_OWNERS, false, null, null, null, null, null, null); dbInstance.commitAndCloseSession(); OLATResource resource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();