diff --git a/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksController.java b/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksController.java index 5aa51118eaa76df9629d02aa27a0e1b3ddacb9e0..65332b25857f3c792fa678fd0c8ed76e85d8c0c1 100644 --- a/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksController.java +++ b/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksController.java @@ -56,8 +56,8 @@ import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory; import org.olat.core.gui.translator.Translator; import org.olat.core.util.Util; import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryEntryStatus; import org.olat.repository.RepositoryManager; +import org.olat.repository.RepositoryModule; /** * Description: @@ -227,7 +227,7 @@ public class BookmarksController extends BasicController { private String getBookmarkTitle(Bookmark bookmark) { String title = bookmark.getTitle(); if (bookmark.getEntryStatus().decommissioned()) { - Translator pT = Util.createPackageTranslator(RepositoryEntryStatus.class, locale); + Translator pT = Util.createPackageTranslator(RepositoryModule.class, locale); title = "[" + pT.translate("title.prefix.closed") + "] ".concat(title); } return title; diff --git a/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksPortletRunController.java b/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksPortletRunController.java index f16b81fb0cf5a830477318fa55460be63c63f513..8c8df0eeadfcead95d4f4a194223be9b84e11039 100644 --- a/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksPortletRunController.java +++ b/src/main/java/org/olat/core/commons/services/mark/ui/BookmarksPortletRunController.java @@ -63,9 +63,9 @@ import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.util.Util; import org.olat.core.util.filter.FilterFactory; import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryEntryStatus; import org.olat.repository.RepositoryEntryStatusEnum; import org.olat.repository.RepositoryManager; +import org.olat.repository.RepositoryModule; /** * Description:<br> @@ -339,7 +339,7 @@ public class BookmarksPortletRunController extends AbstractPortletRunController< RepositoryEntryStatusEnum status = bookmark.getEntryStatus(); if (status.decommissioned()) { - Translator pT = Util.createPackageTranslator(RepositoryEntryStatus.class, locale); + Translator pT = Util.createPackageTranslator(RepositoryModule.class, locale); title = "[" + pT.translate("title.prefix.closed") + "] ".concat(title); } return title; diff --git a/src/main/java/org/olat/course/editor/QuickPublishController.java b/src/main/java/org/olat/course/editor/QuickPublishController.java index 992862f7476751e7556711b6b556d3a8c0e7de2b..02bf96d5cc10fc1d76da6c9f663bf8969ab7ede9 100644 --- a/src/main/java/org/olat/course/editor/QuickPublishController.java +++ b/src/main/java/org/olat/course/editor/QuickPublishController.java @@ -34,6 +34,7 @@ import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.core.id.OLATResourceable; +import org.olat.core.util.Util; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.event.MultiUserEvent; import org.olat.core.util.nodes.INode; @@ -45,6 +46,7 @@ import org.olat.course.tree.CourseEditorTreeModel; import org.olat.course.tree.PublishTreeModel; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; +import org.olat.repository.RepositoryModule; import org.olat.resource.OLATResource; import org.springframework.beans.factory.annotation.Autowired; @@ -63,7 +65,7 @@ public class QuickPublishController extends BasicController { private RepositoryManager repositoryManager; public QuickPublishController(UserRequest ureq, WindowControl wControl, ICourse course) { - super(ureq, wControl); + super(ureq, wControl, Util.createPackageTranslator(RepositoryModule.class, ureq.getLocale())); this.courseOres = OresHelper.clone(course); VelocityContainer mainVC = createVelocityContainer("quick_publish"); diff --git a/src/main/java/org/olat/modules/openmeetings/manager/OpenMeetingsManagerImpl.java b/src/main/java/org/olat/modules/openmeetings/manager/OpenMeetingsManagerImpl.java index 147fdfc1cbfbf30a80ff10a05341ae381e87c34b..6e5f70b43f1bdfa64904bfbdca00ea71e018924b 100644 --- a/src/main/java/org/olat/modules/openmeetings/manager/OpenMeetingsManagerImpl.java +++ b/src/main/java/org/olat/modules/openmeetings/manager/OpenMeetingsManagerImpl.java @@ -61,8 +61,8 @@ import org.olat.modules.openmeetings.model.OpenMeetingsRoom; import org.olat.modules.openmeetings.model.OpenMeetingsRoomReference; import org.olat.modules.openmeetings.model.OpenMeetingsUser; import org.olat.modules.openmeetings.model.RoomReturnInfo; -import org.olat.repository.RepositoryManager; -import org.olat.repository.model.RepositoryEntryShortImpl; +import org.olat.repository.RepositoryEntry; +import org.olat.repository.manager.RepositoryEntryDAO; import org.olat.user.DisplayPortraitManager; import org.olat.user.UserDataDeletable; import org.springframework.beans.factory.annotation.Autowired; @@ -85,7 +85,7 @@ public class OpenMeetingsManagerImpl implements OpenMeetingsManager, UserDataDel @Autowired private CoordinatorManager coordinator; @Autowired - private RepositoryManager repositoryManager; + private RepositoryEntryDAO repositoryEntryDao; @Autowired private DisplayPortraitManager portraitManager; @@ -188,8 +188,8 @@ public class OpenMeetingsManagerImpl implements OpenMeetingsManager, UserDataDel } if(!resourceIdToRoomIds.isEmpty()) { - List<RepositoryEntryShortImpl> shortRepos = repositoryManager.loadRepositoryEntryShortsByResource(resourceIdToRoomIds.keySet(), "CourseModule"); - for(RepositoryEntryShortImpl repoEntry : shortRepos) { + List<RepositoryEntry> shortRepos = repositoryEntryDao.loadByResourceIds("CourseModule", resourceIdToRoomIds.keySet()); + for(RepositoryEntry repoEntry : shortRepos) { List<Long> roomIds = resourceIdToRoomIds.get(repoEntry.getOlatResource().getResourceableId()); for(Long roomId:roomIds) { roomIdToResourceName.put(roomId, repoEntry.getDisplayname()); diff --git a/src/main/java/org/olat/repository/RepositoryEntry.hbm.xml b/src/main/java/org/olat/repository/RepositoryEntry.hbm.xml deleted file mode 100644 index 6c9bf4248955c2b92185a46d2f127820e55fb6da..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/RepositoryEntry.hbm.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> -<hibernate-mapping> - <class name="org.olat.repository.model.RepositoryEntryShortImpl" table="o_repositoryentry" mutable="false"> - <id name="key" column="repositoryentry_id" type="long" unsaved-value="null"> - <generator class="enhanced-sequence"> - <param name="sequence_name">hibernate_unique_key</param> - <param name="force_table_use">true</param> - <param name="optimizer">legacy-hilo</param> - <param name="value_column">next_hi</param> - <param name="increment_size">32767</param> - <param name="initial_value">32767</param> - </generator> - </id> - - <property name="displayname" column="displayname" type="string"/> - <property name="description" column="description" type="string"/> - <property name="status" column="status" type="string"/> - <property name="allUsers" column="allusers" type="boolean"/> - <property name="guests" column="guests" type="boolean"/> - - <many-to-one name="olatResource" - column="fk_olatresource" - class="org.olat.resource.OLATResourceImpl" - outer-join="true" - unique="true" - cascade="none"/> - </class> - - <query name="loadRepositoryEntryShortsByResourceableIds"> - <![CDATA[select v from org.olat.repository.model.RepositoryEntryShortImpl v inner join fetch v.olatResource as ores where ores.resId in (:resIds) and ores.resName=:resName]]> - </query> - -</hibernate-mapping> diff --git a/src/main/java/org/olat/repository/RepositoryEntry.java b/src/main/java/org/olat/repository/RepositoryEntry.java index 1714a2ca32c99a6f3feb794e23c0127f75b567ea..1b8d339d068270271946d7cc6d009973575554d7 100644 --- a/src/main/java/org/olat/repository/RepositoryEntry.java +++ b/src/main/java/org/olat/repository/RepositoryEntry.java @@ -77,6 +77,9 @@ import org.olat.resource.OLATResourceImpl; @NamedQuery(name="loadRepositoryEntryByKey", query="select v from repositoryentry as v inner join fetch v.olatResource as ores inner join fetch v.statistics as statistics left join fetch v.lifecycle as lifecycle where v.key = :repoKey"), @NamedQuery(name="loadRepositoryEntryByResourceKey", query="select v from repositoryentry as v inner join fetch v.olatResource as ores inner join fetch v.statistics as statistics left join fetch v.lifecycle as lifecycle where ores.key = :resourceKey"), @NamedQuery(name="loadRepositoryEntryByResourceId", query="select v from repositoryentry as v inner join fetch v.olatResource as ores inner join fetch v.statistics as statistics left join fetch v.lifecycle as lifecycle where ores.resId=:resId and ores.resName=:resName"), + @NamedQuery(name="loadRepositoryEntryByResourceIds", query="select v from repositoryentry as v inner join fetch v.olatResource as ores inner join fetch v.statistics as statistics left join fetch v.lifecycle as lifecycle where ores.resId in (:resIds) and ores.resName=:resName"), + + @NamedQuery(name="getDisplayNameByResourceKey", query="select v.displayname from repositoryentry v where v.olatResource.key=:resKey"), @NamedQuery(name="getDisplayNameByOlatResourceRedId", query="select v.displayname from repositoryentry v inner join v.olatResource as ores where ores.resId=:resid"), @NamedQuery(name="getDisplayNameByRepositoryEntryKey", query="select v.displayname from repositoryentry v where v.key=:reKey") diff --git a/src/main/java/org/olat/repository/RepositoryEntryStatus.java b/src/main/java/org/olat/repository/RepositoryEntryStatus.java deleted file mode 100644 index 5497c5a719224ad1e645ba18c3d18bce3ab10980..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/RepositoryEntryStatus.java +++ /dev/null @@ -1,80 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository; -/** - * - * Description:<br> - * This class is used to handle and interpret the status of repository entries. - * - * <P> - * Initial Date: 09.07.2009 <br> - * @author bja <bja@bps-system.de> - */ -public class RepositoryEntryStatus { - - public static final int REPOSITORY_STATUS_OPEN = 0; - /** - * Correspond to the "freeze" status - */ - public static final int REPOSITORY_STATUS_CLOSED = 2; - public static final int REPOSITORY_STATUS_UNPUBLISHED = 4; - - private boolean closed; - private boolean unpublished; - - public RepositoryEntryStatus(int statusCode) { - // initialize closed status - if((statusCode & REPOSITORY_STATUS_CLOSED) == REPOSITORY_STATUS_CLOSED ) { - setClosed(true); - } else { - setClosed(false); - } - - if((statusCode & REPOSITORY_STATUS_UNPUBLISHED) == REPOSITORY_STATUS_UNPUBLISHED ) { - setUnpublished(true); - } else { - setUnpublished(false); - } - } - - /** - * @param closed - */ - private void setClosed(boolean closed) { - this.closed = closed; - } - - public boolean isClosed() { - return closed; - } - - private void setUnpublished(boolean unpublished) { - this.unpublished = unpublished; - } - - public boolean isUnpublished() { - return unpublished; - } -} diff --git a/src/main/java/org/olat/repository/RepositoryEntryStatusEnum.java b/src/main/java/org/olat/repository/RepositoryEntryStatusEnum.java index 1565c31c55654eb314fff83d65bba900a49e87fd..6da77fa681f272d51133f9955fca85c24e0fffc8 100644 --- a/src/main/java/org/olat/repository/RepositoryEntryStatusEnum.java +++ b/src/main/java/org/olat/repository/RepositoryEntryStatusEnum.java @@ -80,20 +80,6 @@ public enum RepositoryEntryStatusEnum { }; } - public static RepositoryEntryStatusEnum[] authors() { - return new RepositoryEntryStatusEnum[] { - RepositoryEntryStatusEnum.preparation, RepositoryEntryStatusEnum.review, - RepositoryEntryStatusEnum.coachpublished, RepositoryEntryStatusEnum.published, - RepositoryEntryStatusEnum.closed - }; - } - - public static RepositoryEntryStatusEnum[] users() { - return new RepositoryEntryStatusEnum[] { - RepositoryEntryStatusEnum.published, RepositoryEntryStatusEnum.closed - }; - } - public static boolean isValid(String string) { boolean allOk = false; if(StringHelper.containsNonWhitespace(string)) { diff --git a/src/main/java/org/olat/repository/RepositoryManager.java b/src/main/java/org/olat/repository/RepositoryManager.java index 8904013424d074667838a4e1b393fb07f10eb9f5..3ab86397ddaff194b9e096691c26edc027a2f03d 100644 --- a/src/main/java/org/olat/repository/RepositoryManager.java +++ b/src/main/java/org/olat/repository/RepositoryManager.java @@ -48,7 +48,6 @@ import org.olat.core.commons.modules.bc.FolderConfig; import org.olat.core.commons.modules.bc.meta.MetaInfo; import org.olat.core.commons.modules.bc.meta.tagged.MetaTagged; import org.olat.core.commons.persistence.DB; -import org.olat.core.commons.persistence.PersistenceHelper; import org.olat.core.commons.persistence.QueryBuilder; import org.olat.core.commons.services.image.ImageService; import org.olat.core.commons.services.image.Size; @@ -86,7 +85,6 @@ import org.olat.repository.model.RepositoryEntryMembership; import org.olat.repository.model.RepositoryEntryMembershipModifiedEvent; import org.olat.repository.model.RepositoryEntryPermissionChangeEvent; import org.olat.repository.model.RepositoryEntrySecurity; -import org.olat.repository.model.RepositoryEntryShortImpl; import org.olat.repository.model.RepositoryEntryToGroupRelation; import org.olat.repository.model.SearchRepositoryEntryParameters; import org.olat.resource.OLATResource; @@ -481,36 +479,7 @@ public class RepositoryManager { .getResultList(); } - /** - * Load a list of repository entry without all the security groups ... - * @param resources - * @return - */ - public List<RepositoryEntryShort> loadRepositoryEntryShorts(List<OLATResource> resources) { - StringBuilder sb = new StringBuilder(); - sb.append("select v from ").append(RepositoryEntryShortImpl.class.getName()).append(" v ") - .append(" inner join fetch v.olatResource as ores") - .append(" where ores.key in (:resKeys)"); - - List<Long> resourceKeys = PersistenceHelper.toKeys(resources); - return dbInstance.getCurrentEntityManager() - .createQuery(sb.toString(), RepositoryEntryShort.class) - .setParameter("resKeys", resourceKeys) - .getResultList(); - } - /** - * Load a list of repository entry without all the security groups ... - * @param resources - * @return - */ - public List<RepositoryEntryShortImpl> loadRepositoryEntryShortsByResource(Collection<Long> resIds, String resourceType) { - return dbInstance.getCurrentEntityManager() - .createNamedQuery("loadRepositoryEntryShortsByResourceableIds", RepositoryEntryShortImpl.class) - .setParameter("resIds", resIds) - .setParameter("resName", resourceType) - .getResultList(); - } public RepositoryEntrySecurity isAllowed(UserRequest ureq, RepositoryEntry re) { return isAllowed(ureq.getIdentity(), ureq.getUserSession().getRoles(), re); @@ -890,7 +859,7 @@ public class RepositoryManager { QueryBuilder query = new QueryBuilder(400); query.append("select count(*) from repositoryentry v") .append(" inner join v.olatResource res") - .append(" where res.resName=:restrictedType and v.status ").in(RepositoryEntryStatusEnum.authors()); + .append(" where res.resName=:restrictedType and v.status ").in(RepositoryEntryStatusEnum.preparationToClosed()); List<Number> count = dbInstance.getCurrentEntityManager() .createQuery(query.toString(), Number.class) .setParameter("restrictedType", restrictedType) @@ -1124,7 +1093,7 @@ public class RepositoryManager { .append(" inner join v.groups as relGroup on relGroup.defaultGroup=true") .append(" inner join relGroup.group as baseGroup")//TODO repo access .append(" inner join baseGroup.members as membership on membership.role='").append(GroupRoles.owner.name()).append("'") - .append(" where membership.identity.key=:identityKey and v.status ").in(RepositoryEntryStatusEnum.authors()); + .append(" where membership.identity.key=:identityKey and v.status ").in(RepositoryEntryStatusEnum.preparationToClosed()); return dbInstance.getCurrentEntityManager() .createQuery(sb.toString(), RepositoryEntry.class) .setParameter("identityKey", identity.getKey()) @@ -1627,9 +1596,9 @@ public class RepositoryManager { return query.getResultList(); } - public List<RepositoryEntryLight> getParticipantRepositoryEntry(IdentityRef identity, int maxResults, RepositoryEntryOrder... orderby) { + public List<RepositoryEntry> getParticipantRepositoryEntry(IdentityRef identity, int maxResults, RepositoryEntryOrder... orderby) { QueryBuilder sb = new QueryBuilder(512); - sb.append("select v from repoentrylight as v ") + sb.append("select v from repositoryentry as v ") .append(" inner join fetch v.olatResource as res ") .append(" where (exists (select rel from repoentrytogroup as rel, bgroup as baseGroup, bgroupmember as membership") .append(" where rel.entry=v and rel.group=baseGroup and membership.group=baseGroup and membership.identity.key=:identityKey") @@ -1637,8 +1606,8 @@ public class RepositoryManager { .append(" or v.allUsers=true) and v.status").in(RepositoryEntryStatusEnum.publishedAndClosed()); appendOrderBy(sb, "v", orderby); - TypedQuery<RepositoryEntryLight> query = dbInstance.getCurrentEntityManager() - .createQuery(sb.toString(), RepositoryEntryLight.class) + TypedQuery<RepositoryEntry> query = dbInstance.getCurrentEntityManager() + .createQuery(sb.toString(), RepositoryEntry.class) .setParameter("identityKey", identity.getKey()); if(maxResults > 0) { query.setMaxResults(maxResults); diff --git a/src/main/java/org/olat/repository/RepositoryModule.java b/src/main/java/org/olat/repository/RepositoryModule.java index 2c2d08f5e6bafe74a9734e1e13106ab3bdda1125..70b0fd966cb17fbcea09b517b69031c4aec3ca88 100644 --- a/src/main/java/org/olat/repository/RepositoryModule.java +++ b/src/main/java/org/olat/repository/RepositoryModule.java @@ -64,7 +64,6 @@ public class RepositoryModule extends AbstractSpringModule { private static final String ALLOW_TO_LEAVE_DEFAULT_OPTION = "repo.allow.to.leave"; private static final String LIFECYCLE_AUTO_CLOSE = "repo.lifecycle.auto.close"; - private static final String LIFECYCLE_AUTO_UNPUBLISH = "repo.lifecycle.auto.unpublish"; private static final String LIFECYCLE_AUTO_DELETE = "repo.lifecycle.auto.delete"; @Value("${site.catalog.enable:true}") @@ -87,8 +86,6 @@ public class RepositoryModule extends AbstractSpringModule { @Value("${repo.lifecycle.auto.close:}") private String lifecycleAutoClose; - @Value("${repo.lifecycle.auto.unpublish:}") - private String lifecycleAutoUnpublish; @Value("${repo.lifecycle.auto.delete:}") private String lifecycleAutoDelete; @@ -190,11 +187,6 @@ public class RepositoryModule extends AbstractSpringModule { lifecycleAutoClose = autoClose; } - String autoUnpublish = getStringPropertyValue(LIFECYCLE_AUTO_UNPUBLISH, true); - if(StringHelper.containsNonWhitespace(autoUnpublish)) { - lifecycleAutoUnpublish = autoUnpublish; - } - String autoDelete = getStringPropertyValue(LIFECYCLE_AUTO_DELETE, true); if(StringHelper.containsNonWhitespace(autoDelete)) { lifecycleAutoDelete = autoDelete; @@ -324,19 +316,6 @@ public class RepositoryModule extends AbstractSpringModule { setStringProperty(LIFECYCLE_AUTO_CLOSE, lifecycleAutoClose, true); } - public String getLifecycleAutoUnpublish() { - return lifecycleAutoUnpublish; - } - - public RepositoryEntryLifeCycleValue getLifecycleAutoUnpublishValue() { - return RepositoryEntryLifeCycleValue.parse(lifecycleAutoUnpublish); - } - - public void setLifecycleAutoUnpublish(String lifecycleAutoUnpublish) { - this.lifecycleAutoUnpublish = lifecycleAutoUnpublish; - setStringProperty(LIFECYCLE_AUTO_UNPUBLISH, lifecycleAutoUnpublish, true); - } - public String getLifecycleAutoDelete() { return lifecycleAutoDelete; } diff --git a/src/main/java/org/olat/repository/RepositoryService.java b/src/main/java/org/olat/repository/RepositoryService.java index 24fd83c8b04821ec126c318b6eb1d870f2b4b0a5..887b53adb10ad81a3b02b68b25185e3849c97051 100644 --- a/src/main/java/org/olat/repository/RepositoryService.java +++ b/src/main/java/org/olat/repository/RepositoryService.java @@ -139,15 +139,6 @@ public interface RepositoryService { public RepositoryEntry uncloseRepositoryEntry(RepositoryEntry entry); - /** - * The unpublish will remove the users (coaches and participants) but will let - * the owners. Catalog entries will be removed and the relations to the business groups - * will be deleted. - * - * @param entry - * @return - */ - public RepositoryEntry unpublishRepositoryEntry(RepositoryEntry entry); /** * Increment the launch counter and the last usage date. diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties index 6c5ce072aa804188cbfd5c5810cf9397c325e53b..f2e0b239f05aa18b87217b5611e029b9f859aebd 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties @@ -66,8 +66,6 @@ bulk.update.nothing.selected=Sie m\u00FCssen mindestens eine Lernressource zur B bulk.update.nothing.applicable.selected=Diese Aktion ist auf keine der ausgew\u00E4hlten Lernressourcen anwendbar. change.to.close=Beendet change.to.close.text=wechselt zu beenden (Benutzer behalten den Zugriff, Lesemodus) -change.to.unpublish=Unpublizieren -change.to.unpublish.text=wechselt zu unpubliziert (entfernt alle Benutzer, wird aus dem Katalog entfernt) change.to.delete=L\u00F6schen change.to.delete.text=wechselt zu gel\u00F6scht (Bezitzer wird entfernt, Kurs befindet sich im Papierkorb) cap.launch=Die Lernressource wird geladen. Bitte warten... diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties index 8de1a25d272ede1cebc3e940013942e19d0afd0e..e3132affb9121328f1484bf3b7d06d0b9c6cdb8c 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties @@ -71,8 +71,6 @@ change.to.close=Finish change.to.close.text=change to finished (read only, keep user access) change.to.delete=Delete change.to.delete.text=change to deleted (remove owners, put into trash) -change.to.unpublish=Unpublish -change.to.unpublish.text=change to unpublished (remove users, remove from catalog) chkbx.calendar.onoff=Use calendar chkbx.chat.onoff=Use course chat chkbx.efficency.onoff=Use evidence of achievement diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties index 9b0fb9e6230e5d23f7270bced742e36074131e3b..e635713237feadfe318bbe8fab972d282ca5b30b 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties @@ -71,8 +71,6 @@ change.to.close=Clore change.to.close.text=passer \u00E0 termin\u00E9 (en lecture seule, les utilisateurs conservent leur droit d'acc\u00E8s) change.to.delete=Effacer change.to.delete.text=passer \u00E0 effac\u00E9 (enlever les propri\u00E9taires, mis \u00E0 la corbeille) -change.to.unpublish=Non publi\u00E9 -change.to.unpublish.text=passer \u00E0 non publi\u00E9 (enl\u00E8ve les utilisateurs, sorti du catalogue) chkbx.calendar.onoff=Utiliser calendrier chkbx.chat.onoff=utiliser chat du cours chkbx.efficency.onoff=Utiliser attestation de performance diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_it.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_it.properties index 4af69edc743c14541eb9ba405aab8096508f4e72..c1c9276cfe4a675a301779038ac874e960bb8047 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_it.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_it.properties @@ -71,8 +71,6 @@ change.to.close=Fine change.to.close.text=modificare a terminato (sola lettura, accessi utente mantenuti) change.to.delete=Eliminare change.to.delete.text=modificare a eliminato (rimuovere proprietari, spostare nel cestino) -change.to.unpublish=Rendere privato -change.to.unpublish.text=modificare a non pubblicato (rimuovere utenti, rimuovere dal catalogo) chkbx.calendar.onoff=Utilizza calendario chkbx.chat.onoff=Utilizza chat di corso chkbx.efficency.onoff=Utilizza attestato di efficienza diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_pt_BR.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_pt_BR.properties index 4024de55f7bf65e67c7330341e595971a0522be9..412c734a3eea7c5d45b39833ba963c3702e7d1f8 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_pt_BR.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_pt_BR.properties @@ -71,8 +71,6 @@ change.to.close=Terminar change.to.close.text=Mudar para conclu\u00EDdo (somente leitura, mant\u00E9m acesso de usu\u00E1rio) change.to.delete=Excluir change.to.delete.text=mudar para exclu\u00EDdo (remover propriet\u00E1rios, colocar no lixo) -change.to.unpublish=N\u00E3o-publicar -change.to.unpublish.text=mudar para n\u00E3o-publicado (remover usu\u00E1rios, retirar do cat\u00E1logo) chkbx.calendar.onoff=Usar calend\u00E1rio chkbx.chat.onoff=Usar bate-papo do curso chkbx.efficency.onoff=Usar comprovante de conclus\u00E3o diff --git a/src/main/java/org/olat/repository/manager/AutomaticLifecycleService.java b/src/main/java/org/olat/repository/manager/AutomaticLifecycleService.java index 25bbccb6f3c4a44d5131f7b9c06280d34c8bad5a..b53baa934b97a186820ee58e121509cd64aa94dc 100644 --- a/src/main/java/org/olat/repository/manager/AutomaticLifecycleService.java +++ b/src/main/java/org/olat/repository/manager/AutomaticLifecycleService.java @@ -102,48 +102,6 @@ public class AutomaticLifecycleService { .setParameter("now", endOfDay) .getResultList(); } - /* - private void unpublish() { - String autoUnpublish = repositoryModule.getLifecycleAutoUnpublish(); - if(StringHelper.containsNonWhitespace(autoUnpublish)) { - RepositoryEntryLifeCycleValue autoUnpublishVal = RepositoryEntryLifeCycleValue.parse(autoUnpublish); - Date markerDate = autoUnpublishVal.limitDate(new Date()); - List<RepositoryEntry> entriesToUnpublish = getRepositoryEntriesToUnpublish(markerDate); - for(RepositoryEntry entry:entriesToUnpublish) { - try { - boolean closeManaged = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.close); - if(!closeManaged) { - log.audit("Automatic unpublishing course: " + entry.getDisplayname() + " [" + entry.getKey() + "]"); - repositoryService.unpublishRepositoryEntry(entry); - dbInstance.commit(); - } - } catch (Exception e) { - log.error("", e); - dbInstance.commitAndCloseSession(); - } - } - } - } - - public List<RepositoryEntry> getRepositoryEntriesToUnpublish(Date date) { - StringBuilder sb = new StringBuilder();//TODO repo unit - sb.append("select v from repositoryentry as v ") - .append(" inner join fetch v.olatResource as ores") - .append(" inner join fetch v.statistics as statistics") - .append(" inner join fetch v.lifecycle as lifecycle") - .append(" where lifecycle.validTo<:now and not(v.statusCode=").append(RepositoryEntryStatus.REPOSITORY_STATUS_UNPUBLISHED).append(")") - .append(" and v.access>=").append(RepositoryEntry.ACC_OWNERS);//TODO repo access - - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - CalendarUtils.getEndOfDay(cal); - Date endOfDay = cal.getTime(); - - return dbInstance.getCurrentEntityManager() - .createQuery(sb.toString(), RepositoryEntry.class) - .setParameter("now", endOfDay) - .getResultList(); - }*/ private void delete() { String autoDelete = repositoryModule.getLifecycleAutoDelete(); diff --git a/src/main/java/org/olat/repository/manager/RepositoryEntryDAO.java b/src/main/java/org/olat/repository/manager/RepositoryEntryDAO.java index 83dd08e7b58d13fd321049250b1fb01c9b64570d..30038d0c73e206976facbc4ed2961d45fb010885 100644 --- a/src/main/java/org/olat/repository/manager/RepositoryEntryDAO.java +++ b/src/main/java/org/olat/repository/manager/RepositoryEntryDAO.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; import javax.persistence.LockModeType; import javax.persistence.TypedQuery; @@ -85,6 +86,22 @@ public class RepositoryEntryDAO { } return entries.get(0); } + + public RepositoryEntry loadByResource(OLATResource resource) { + List<RepositoryEntry> entries = dbInstance.getCurrentEntityManager() + .createNamedQuery("loadRepositoryEntryByResourceKey", RepositoryEntry.class) + .setParameter("resourceKey", resource.getKey()) + .getResultList(); + if(entries.isEmpty()) { + return null; + } + return entries.get(0); + } + + public List<RepositoryEntry> loadByResources(Collection<OLATResource> resources) { + List<Long> resourceKeys = resources.stream().map(OLATResource::getKey).collect(Collectors.toList()); + return loadByResourceKeys(resourceKeys); + } public List<RepositoryEntry> loadByResourceKeys(Collection<Long> resourceKeys) { if(resourceKeys == null || resourceKeys.isEmpty()) return Collections.emptyList(); @@ -136,6 +153,14 @@ public class RepositoryEntryDAO { return entries.get(0); } + public List<RepositoryEntry> loadByResourceIds(String resourceName, Collection<Long> resourceIds) { + return dbInstance.getCurrentEntityManager() + .createNamedQuery("loadRepositoryEntryByResourceIds", RepositoryEntry.class) + .setParameter("resIds", resourceIds) + .setParameter("resName", resourceName) + .getResultList(); + } + public List<RepositoryEntry> searchByIdAndRefs(String idAndRefs) { StringBuilder sb = new StringBuilder(); sb.append("select v from ").append(RepositoryEntry.class.getName()).append(" as v ") diff --git a/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java b/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java index 4073996363c3d615557d537588ae84b967252ed1..45a9c99fc544d01460ba74d5b6205314f901dfd1 100644 --- a/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java +++ b/src/main/java/org/olat/repository/manager/RepositoryServiceImpl.java @@ -527,27 +527,6 @@ public class RepositoryServiceImpl implements RepositoryService { return reloadedEntry; } - @Override - public RepositoryEntry unpublishRepositoryEntry(RepositoryEntry entry) { - RepositoryEntry reloadedEntry = repositoryEntryDAO.loadForUpdate(entry); - reloadedEntry.setEntryStatus(RepositoryEntryStatusEnum.trash); - reloadedEntry = dbInstance.getCurrentEntityManager().merge(reloadedEntry); - dbInstance.commit(); - // remove catalog entries - catalogManager.resourceableDeleted(reloadedEntry); - // remove users and participants - //remove participant and coach - removeMembers(reloadedEntry, GroupRoles.coach.name(), GroupRoles.participant.name(), GroupRoles.waiting.name()); - //remove relation to business groups - List<RepositoryEntryToGroupRelation> relations = reToGroupDao.getRelations(reloadedEntry); - for(RepositoryEntryToGroupRelation relation:relations) { - if(!relation.isDefaultGroup()) { - reToGroupDao.removeRelation(relation); - } - } - return reloadedEntry; - } - @Override public void incrementLaunchCounter(RepositoryEntry re) { repositoryEntryStatisticsDao.incrementLaunchCounter(re); diff --git a/src/main/java/org/olat/repository/model/RepositoryEntryLightImpl.java b/src/main/java/org/olat/repository/model/RepositoryEntryLightImpl.java deleted file mode 100644 index 4364c75f47a81d39e6940c109a78a46dd2525b96..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/model/RepositoryEntryLightImpl.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * <a href="http://www.openolat.org"> - * OpenOLAT - Online Learning and Training</a><br> - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); <br> - * you may not use this file except in compliance with the License.<br> - * You may obtain a copy of the License at the - * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> - * <p> - * Unless required by applicable law or agreed to in writing,<br> - * software distributed under the License is distributed on an "AS IS" BASIS, <br> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> - * See the License for the specific language governing permissions and <br> - * limitations under the License. - * <p> - * Initial code contributed and copyrighted by<br> - * frentix GmbH, http://www.frentix.com - * <p> - */ -package org.olat.repository.model; - -import java.util.Set; - -import javax.persistence.Cacheable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; -import javax.persistence.Table; - -import org.hibernate.annotations.GenericGenerator; -import org.hibernate.annotations.Parameter; -import org.olat.core.id.Persistable; -import org.olat.repository.RepositoryEntryLight; -import org.olat.repository.RepositoryEntryStatusEnum; -import org.olat.resource.OLATResource; -import org.olat.resource.OLATResourceImpl; - -/** - * - * Initial date: 15.07.2013<br> - * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com - * - */ -@Cacheable(false) -@Entity(name="repoentrylight") -@Table(name="o_repositoryentry") -@NamedQueries({ - @NamedQuery(name="loadLightReByKey", query="select v from repoentrylight v where v.key=:repoKey") -}) -public class RepositoryEntryLightImpl implements RepositoryEntryLight, Persistable { - - private static final long serialVersionUID = 5427458190644827372L; - - @Id - @GeneratedValue(generator = "system-uuid") - @GenericGenerator(name = "system-uuid", strategy = "enhanced-sequence", parameters={ - @Parameter(name="sequence_name", value="hibernate_unique_key"), - @Parameter(name="force_table_use", value="true"), - @Parameter(name="optimizer", value="legacy-hilo"), - @Parameter(name="value_column", value="next_hi"), - @Parameter(name="increment_size", value="32767"), - @Parameter(name="initial_value", value="32767") - }) - @Column(name="repositoryentry_id", nullable=false, unique=true, insertable=true, updatable=false) - private Long key; - - @Column(name="displayname", nullable=false, insertable=false, updatable=false) - private String displayname; - @Column(name="description", nullable=false, insertable=false, updatable=false) - private String description; - - @Column(name="status", nullable=false, insertable=true, updatable=true) - private String status; - @Column(name="allusers", nullable=false, insertable=true, updatable=true) - private boolean allUsers; - @Column(name="guests", nullable=false, insertable=true, updatable=true) - private boolean guests; - - @ManyToOne(targetEntity=OLATResourceImpl.class,fetch=FetchType.LAZY, optional=false) - @JoinColumn(name="fk_olatresource", nullable=false, insertable=true, updatable=false) - private OLATResource olatResource; - - @OneToMany(targetEntity=RepositoryEntryToGroupRelation.class, fetch=FetchType.LAZY) - @JoinColumn(name="fk_entry_id") - private Set<RepositoryEntryToGroupRelation> groups; - - public Long getKey() { - return key; - } - - @Override - public String getDisplayname() { - return displayname; - } - - public void setDisplayname(String displayname) { - this.displayname = displayname; - } - - @Override - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - @Override - public String getResourceType() { - return olatResource.getResourceableTypeName(); - } - - public OLATResource getOlatResource() { - return olatResource; - } - - public void setOlatResource(OLATResource olatResource) { - this.olatResource = olatResource; - } - - public Set<RepositoryEntryToGroupRelation> getGroups() { - return groups; - } - - public void setGroups(Set<RepositoryEntryToGroupRelation> groups) { - this.groups = groups; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - @Override - public RepositoryEntryStatusEnum getEntryStatus() { - return RepositoryEntryStatusEnum.valueOf(status); - } - - @Override - public boolean isAllUsers() { - return allUsers; - } - - public void setAllUsers(boolean allUsers) { - this.allUsers = allUsers; - } - @Override - public boolean isGuests() { - return guests; - } - - public void setGuests(boolean guests) { - this.guests = guests; - } - - @Override - public int hashCode() { - return key == null ? 891265 : key.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof RepositoryEntryLightImpl) { - RepositoryEntryLightImpl other = (RepositoryEntryLightImpl) obj; - return getKey().equals(other.getKey()); - } - return false; - } - - @Override - public boolean equalsByPersistableKey(Persistable persistable) { - return equals(persistable); - } -} \ No newline at end of file diff --git a/src/main/java/org/olat/repository/model/RepositoryEntryShortImpl.java b/src/main/java/org/olat/repository/model/RepositoryEntryShortImpl.java deleted file mode 100644 index 192b88e4f0d8e389f8de927396532e907d43f206..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/model/RepositoryEntryShortImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * <a href="http://www.openolat.org"> - * OpenOLAT - Online Learning and Training</a><br> - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); <br> - * you may not use this file except in compliance with the License.<br> - * You may obtain a copy of the License at the - * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> - * <p> - * Unless required by applicable law or agreed to in writing,<br> - * software distributed under the License is distributed on an "AS IS" BASIS, <br> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> - * See the License for the specific language governing permissions and <br> - * limitations under the License. - * <p> - * Initial code contributed and copyrighted by<br> - * frentix GmbH, http://www.frentix.com - * <p> - */ -package org.olat.repository.model; - -import org.olat.core.commons.persistence.PersistentObject; -import org.olat.repository.RepositoryEntryShort; -import org.olat.repository.RepositoryEntryStatusEnum; -import org.olat.resource.OLATResource; - -/** - * - * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com - */ -public class RepositoryEntryShortImpl extends PersistentObject implements RepositoryEntryShort { - - private static final long serialVersionUID = 4599683374800325931L; - - private String displayName; - private String description; - private OLATResource resource; - private String status; - private boolean allUsers; - private boolean guests; - - - @Override - public String getDisplayname() { - return displayName; - } - - public void setDisplayname(String displayName) { - this.displayName = displayName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - @Override - public String getResourceType() { - return resource.getResourceableTypeName(); - } - - - public OLATResource getOlatResource() { - return resource; - } - - public void setOlatResource(OLATResource resource) { - this.resource = resource; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - @Override - public RepositoryEntryStatusEnum getEntryStatus() { - return RepositoryEntryStatusEnum.valueOf(status); - } - - public boolean isAllUsers() { - return allUsers; - } - - public void setAllUsers(boolean allUsers) { - this.allUsers = allUsers; - } - - public boolean isGuests() { - return guests; - } - - public void setGuests(boolean guests) { - this.guests = guests; - } - - @Override - public int hashCode() { - return getKey().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof RepositoryEntryShortImpl) { - RepositoryEntryShortImpl other = (RepositoryEntryShortImpl) obj; - return getKey().equals(other.getKey()); - } - return false; - } -} \ No newline at end of file diff --git a/src/main/java/org/olat/repository/portlet/RepositoryPortlet.java b/src/main/java/org/olat/repository/portlet/RepositoryPortlet.java index 8dd69af41565a7d40878e586cf4087ebe2ffaae8..d029cda14a236ee722f5c61070503355b42e8f2b 100644 --- a/src/main/java/org/olat/repository/portlet/RepositoryPortlet.java +++ b/src/main/java/org/olat/repository/portlet/RepositoryPortlet.java @@ -30,7 +30,7 @@ import org.olat.core.gui.control.generic.portal.Portlet; import org.olat.core.gui.control.generic.portal.PortletToolController; import org.olat.core.gui.translator.Translator; import org.olat.core.util.Util; -import org.olat.repository.RepositoryEntryLight; +import org.olat.repository.RepositoryEntry; /** * Description:<br> @@ -47,11 +47,6 @@ public class RepositoryPortlet extends AbstractPortlet { private static final String CONFIG_KEY_ROLE_STUDENT = "student"; protected static final String CONFIG_KEY_ROLE_TEACHER = "teacher"; - - /** - * @see org.olat.gui.control.generic.portal.AbstractPortlet#createInstance(org.olat.core.gui.control.WindowControl, - * org.olat.core.gui.UserRequest, java.util.Map) - */ @Override public Portlet createInstance(WindowControl wControl, UserRequest ureq, Map<String,String> configuration) { Translator translator = Util.createPackageTranslator(RepositoryPortlet.class, ureq.getLocale()); @@ -63,9 +58,6 @@ public class RepositoryPortlet extends AbstractPortlet { return p; } - /** - * @see org.olat.gui.control.generic.portal.Portlet#getTitle() - */ @Override public String getTitle() { if (CONFIG_KEY_ROLE_STUDENT.equals(getConfiguration().get(CONFIG_KEY_ROLE))) { @@ -75,9 +67,6 @@ public class RepositoryPortlet extends AbstractPortlet { } } - /** - * @see org.olat.gui.control.generic.portal.Portlet#getDescription() - */ @Override public String getDescription() { if (CONFIG_KEY_ROLE_STUDENT.equals(getConfiguration().get(CONFIG_KEY_ROLE))) { @@ -87,10 +76,6 @@ public class RepositoryPortlet extends AbstractPortlet { } } - /** - * @see org.olat.gui.control.generic.portal.Portlet#getInitialRunComponent(org.olat.core.gui.control.WindowControl, - * org.olat.core.gui.UserRequest) - */ @Override public Component getInitialRunComponent(WindowControl wControl, UserRequest ureq) { if(runCtr != null) runCtr.dispose(); @@ -100,17 +85,11 @@ public class RepositoryPortlet extends AbstractPortlet { return runCtr.getInitialComponent(); } - /** - * @see org.olat.core.gui.control.Disposable#dispose(boolean) - */ @Override public void dispose() { disposeRunComponent(); } - /** - * @see org.olat.gui.control.generic.portal.Portlet#getCssClass() - */ @Override public String getCssClass() { if (CONFIG_KEY_ROLE_STUDENT.equals(getConfiguration().get(CONFIG_KEY_ROLE))) { @@ -120,9 +99,6 @@ public class RepositoryPortlet extends AbstractPortlet { } } - /** - * @see org.olat.gui.control.generic.portal.Portlet#disposeRunComponent(boolean) - */ @Override public void disposeRunComponent() { if (this.runCtr != null) { @@ -132,7 +108,7 @@ public class RepositoryPortlet extends AbstractPortlet { } @Override - public PortletToolController<RepositoryEntryLight> getTools(UserRequest ureq, WindowControl wControl) { + public PortletToolController<RepositoryEntry> getTools(UserRequest ureq, WindowControl wControl) { //portlet was not yet visible if ( runCtr == null ) { boolean studentView = CONFIG_KEY_ROLE_STUDENT.equals(getConfiguration().get(CONFIG_KEY_ROLE)); diff --git a/src/main/java/org/olat/repository/portlet/RepositoryPortletEntry.java b/src/main/java/org/olat/repository/portlet/RepositoryPortletEntry.java index cc951911203bb239a7fbeaa0cfe2f95e869ccb6d..353b37fe9b0f23d50074fe3bff021d1d1c6436a1 100644 --- a/src/main/java/org/olat/repository/portlet/RepositoryPortletEntry.java +++ b/src/main/java/org/olat/repository/portlet/RepositoryPortletEntry.java @@ -21,8 +21,6 @@ package org.olat.repository.portlet; import org.olat.core.gui.control.generic.portal.PortletEntry; import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryEntryLight; -import org.olat.repository.RepositoryEntryStatusEnum; /** * Description:<br> @@ -33,91 +31,26 @@ import org.olat.repository.RepositoryEntryStatusEnum; * * @author gnaegi */ -public class RepositoryPortletEntry implements PortletEntry<RepositoryEntryLight> { - private RepositoryEntryLight value; +public class RepositoryPortletEntry implements PortletEntry<RepositoryEntry> { + + private RepositoryEntry value; - public RepositoryPortletEntry(RepositoryEntryLight repoEntry) { - value = new REShort(repoEntry); - } public RepositoryPortletEntry(RepositoryEntry repoEntry) { - value = new REShort(repoEntry); + value = repoEntry; } + @Override public Long getKey() { return value.getKey(); } - public RepositoryEntryLight getValue() { + @Override + public RepositoryEntry getValue() { return value; } public String getDescription() { return value.getDescription(); } - - private static class REShort implements RepositoryEntryLight { - private final Long key; - private final String displayname; - private final String description; - private final String type; - private final RepositoryEntryStatusEnum status; - private final boolean allUsers; - private final boolean guests; - - public REShort(RepositoryEntryLight entry) { - key = entry.getKey(); - displayname = entry.getDisplayname(); - description = entry.getDescription(); - type = entry.getResourceType(); - status = entry.getEntryStatus(); - allUsers = entry.isAllUsers(); - guests = entry.isGuests(); - } - - public REShort(RepositoryEntry entry) { - key = entry.getKey(); - displayname = entry.getDisplayname(); - description = entry.getDescription(); - type = entry.getOlatResource().getResourceableTypeName(); - status = entry.getEntryStatus(); - allUsers = entry.isAllUsers(); - guests = entry.isGuests(); - } - - @Override - public Long getKey() { - return key; - } - - @Override - public String getDisplayname() { - return displayname; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public RepositoryEntryStatusEnum getEntryStatus() { - return status; - } - - @Override - public boolean isAllUsers() { - return allUsers; - } - - @Override - public boolean isGuests() { - return guests; - } - - @Override - public String getResourceType() { - return type; - } - } } diff --git a/src/main/java/org/olat/repository/portlet/RepositoryPortletRunController.java b/src/main/java/org/olat/repository/portlet/RepositoryPortletRunController.java index 6192f1072c3963107e5cc736b3ee2eb6b4d4abb4..3cba3c897d35847aff05eaa59ddb0688f108ccba 100644 --- a/src/main/java/org/olat/repository/portlet/RepositoryPortletRunController.java +++ b/src/main/java/org/olat/repository/portlet/RepositoryPortletRunController.java @@ -47,7 +47,6 @@ import org.olat.core.gui.control.generic.portal.SortingCriteria; import org.olat.core.gui.translator.Translator; import org.olat.core.util.event.GenericEventListener; import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryEntryLight; import org.olat.repository.RepositoryEntryOrder; import org.olat.repository.RepositoryEntryStatusEnum; import org.olat.repository.RepositoryManager; @@ -63,7 +62,7 @@ import org.olat.repository.ui.RepositoryEntryTypeColumnDescriptor; * Initial Date: 06.03.2009 <br> * @author gnaegi */ -public class RepositoryPortletRunController extends AbstractPortletRunController<RepositoryEntryLight> implements GenericEventListener { +public class RepositoryPortletRunController extends AbstractPortletRunController<RepositoryEntry> implements GenericEventListener { private static final String CMD_LAUNCH = "cmd.launch"; @@ -115,30 +114,25 @@ public class RepositoryPortletRunController extends AbstractPortletRunController putInitialPanel(repoEntriesVC); } - private List<RepositoryEntryLight> getAllEntries(SortingCriteria criteria) { + private List<RepositoryEntry> getAllEntries(SortingCriteria criteria) { int maxResults = criteria == null ? -1 : criteria.getMaxEntries(); RepositoryEntryOrder orderBy = RepositoryEntryOrder.nameAsc; if(criteria != null && !criteria.isAscending()) { orderBy = RepositoryEntryOrder.nameDesc; } - List<RepositoryEntryLight> entries; + List<RepositoryEntry> entries; if (studentView) { entries = RepositoryManager.getInstance().getParticipantRepositoryEntry(getIdentity(), maxResults, orderBy); } else { - List<RepositoryEntry> fullEntries = RepositoryManager.getInstance() - .getLearningResourcesAsTeacher(getIdentity(), 0, maxResults, orderBy); - entries = new ArrayList<>(); - for(RepositoryEntry fullEntry:fullEntries) { - entries.add(new FullReWrapper(fullEntry)); - } + entries = RepositoryManager.getInstance().getLearningResourcesAsTeacher(getIdentity(), 0, maxResults, orderBy); } return entries; } - private List<PortletEntry<RepositoryEntryLight>> convertShortRepositoryEntriesToPortletEntryList(List<RepositoryEntryLight> items) { - List<PortletEntry<RepositoryEntryLight>> convertedList = new ArrayList<>(); - for(RepositoryEntryLight item:items) { + private List<PortletEntry<RepositoryEntry>> convertShortRepositoryEntriesToPortletEntryList(List<RepositoryEntry> items) { + List<PortletEntry<RepositoryEntry>> convertedList = new ArrayList<>(); + for(RepositoryEntry item:items) { RepositoryEntryStatusEnum status = item.getEntryStatus(); if(!status.decommissioned()) { RepositoryPortletEntry entry = new RepositoryPortletEntry(item); @@ -148,8 +142,8 @@ public class RepositoryPortletRunController extends AbstractPortletRunController return convertedList; } - private List<PortletEntry<RepositoryEntryLight>> convertRepositoryEntriesToPortletEntryList(List<RepositoryEntry> items) { - List<PortletEntry<RepositoryEntryLight>> convertedList = new ArrayList<>(); + private List<PortletEntry<RepositoryEntry>> convertRepositoryEntriesToPortletEntryList(List<RepositoryEntry> items) { + List<PortletEntry<RepositoryEntry>> convertedList = new ArrayList<>(); for(RepositoryEntry item:items) { RepositoryEntryStatusEnum status = item.getEntryStatus(); if(!status.decommissioned()) { @@ -163,8 +157,8 @@ public class RepositoryPortletRunController extends AbstractPortletRunController @Override protected void reloadModel(SortingCriteria criteria) { if (criteria.getSortingType() == SortingCriteria.AUTO_SORTING) { - List<RepositoryEntryLight> items = getAllEntries(criteria); - List<PortletEntry<RepositoryEntryLight>> entries = convertShortRepositoryEntriesToPortletEntryList(items); + List<RepositoryEntry> items = getAllEntries(criteria); + List<PortletEntry<RepositoryEntry>> entries = convertShortRepositoryEntriesToPortletEntryList(items); repoEntryListModel = new RepositoryPortletTableDataModel(entries, getLocale()); tableCtr.setTableDataModel(repoEntryListModel); } else { @@ -173,7 +167,7 @@ public class RepositoryPortletRunController extends AbstractPortletRunController } @Override - protected void reloadModel(List<PortletEntry<RepositoryEntryLight>> sortedItems) { + protected void reloadModel(List<PortletEntry<RepositoryEntry>> sortedItems) { repoEntryListModel = new RepositoryPortletTableDataModel(sortedItems, getLocale()); tableCtr.setTableDataModel(repoEntryListModel); } @@ -209,7 +203,7 @@ public class RepositoryPortletRunController extends AbstractPortletRunController String actionid = te.getActionId(); if (actionid.equals(CMD_LAUNCH)) { int rowId = te.getRowId(); - PortletEntry<RepositoryEntryLight> entry = repoEntryListModel.getObject(rowId); + PortletEntry<RepositoryEntry> entry = repoEntryListModel.getObject(rowId); NewControllerFactory.getInstance().launch("[RepositoryEntry:" + entry.getKey() + "]", ureq, getWindowControl()); } } @@ -228,14 +222,14 @@ public class RepositoryPortletRunController extends AbstractPortletRunController * @param wControl * @return a PortletToolSortingControllerImpl instance. */ - protected PortletToolSortingControllerImpl<RepositoryEntryLight> createSortingTool(UserRequest ureq, WindowControl wControl) { + protected PortletToolSortingControllerImpl<RepositoryEntry> createSortingTool(UserRequest ureq, WindowControl wControl) { if(portletToolsController==null) { - List<RepositoryEntryLight> items = getAllEntries(null); - List<PortletEntry<RepositoryEntryLight>> entries = convertShortRepositoryEntriesToPortletEntryList(items); - PortletDefaultTableDataModel<RepositoryEntryLight> tableDataModel = new RepositoryPortletTableDataModel(entries, ureq.getLocale()); - List<PortletEntry<RepositoryEntryLight>> sortedItems = getPersistentManuallySortedItems(); + List<RepositoryEntry> items = getAllEntries(null); + List<PortletEntry<RepositoryEntry>> entries = convertShortRepositoryEntriesToPortletEntryList(items); + PortletDefaultTableDataModel<RepositoryEntry> tableDataModel = new RepositoryPortletTableDataModel(entries, ureq.getLocale()); + List<PortletEntry<RepositoryEntry>> sortedItems = getPersistentManuallySortedItems(); - portletToolsController = new PortletToolSortingControllerImpl<RepositoryEntryLight>(ureq, wControl, getTranslator(), sortingCriteria, tableDataModel, sortedItems); + portletToolsController = new PortletToolSortingControllerImpl<RepositoryEntry>(ureq, wControl, getTranslator(), sortingCriteria, tableDataModel, sortedItems); portletToolsController.setConfigManualSorting(true); portletToolsController.setConfigAutoSorting(true); portletToolsController.addControllerListener(this); @@ -248,14 +242,14 @@ public class RepositoryPortletRunController extends AbstractPortletRunController * @param ureq * @return */ - private List<PortletEntry<RepositoryEntryLight>> getPersistentManuallySortedItems() { + private List<PortletEntry<RepositoryEntry>> getPersistentManuallySortedItems() { @SuppressWarnings("unchecked") Map<Long, Integer> storedPrefs = (Map<Long, Integer>) guiPreferences.get(Map.class, getPreferenceKey(SORTED_ITEMS_PREF)); if(storedPrefs == null) { - return new ArrayList<PortletEntry<RepositoryEntryLight>>(); + return new ArrayList<>(); } List<RepositoryEntry> items = RepositoryManager.getInstance().lookupRepositoryEntries(storedPrefs.keySet()); - List<PortletEntry<RepositoryEntryLight>> entries = convertRepositoryEntriesToPortletEntryList(items); + List<PortletEntry<RepositoryEntry>> entries = convertRepositoryEntriesToPortletEntryList(items); return getPersistentManuallySortedItems(entries); } @@ -267,9 +261,10 @@ public class RepositoryPortletRunController extends AbstractPortletRunController * @return a Comparator for the input sortingCriteria */ @Override - protected Comparator<RepositoryEntryLight> getComparator(final SortingCriteria criteria) { - return new Comparator<RepositoryEntryLight>(){ - public int compare(final RepositoryEntryLight repoEntry1, final RepositoryEntryLight repoEntry2) { + protected Comparator<RepositoryEntry> getComparator(final SortingCriteria criteria) { + return new Comparator<RepositoryEntry>(){ + @Override + public int compare(final RepositoryEntry repoEntry1, final RepositoryEntry repoEntry2) { int comparisonResult = 0; if(criteria.getSortingTerm()==SortingCriteria.ALPHABETICAL_SORTING) { comparisonResult = collator.compare(repoEntry1.getDisplayname(), repoEntry2.getDisplayname()); @@ -281,48 +276,5 @@ public class RepositoryPortletRunController extends AbstractPortletRunController return comparisonResult; }}; } - - private static class FullReWrapper implements RepositoryEntryLight { - - private final RepositoryEntry re; - - public FullReWrapper(RepositoryEntry re) { - this.re = re; - } - - @Override - public Long getKey() { - return re.getKey(); - } - - @Override - public String getDisplayname() { - return re.getDisplayname(); - } - @Override - public String getResourceType() { - return re.getOlatResource().getResourceableTypeName(); - } - - @Override - public String getDescription() { - return re.getDescription(); - } - - @Override - public RepositoryEntryStatusEnum getEntryStatus() { - return re.getEntryStatus(); - } - - @Override - public boolean isAllUsers() { - return re.isAllUsers(); - } - - @Override - public boolean isGuests() { - return re.isGuests(); - } - } } \ No newline at end of file diff --git a/src/main/java/org/olat/repository/portlet/RepositoryPortletTableDataModel.java b/src/main/java/org/olat/repository/portlet/RepositoryPortletTableDataModel.java index fb6b75ed3f229da6e63ed5751dda758cd08561de..9e1ad980ebfcba4d438f6a26094365261133f865 100644 --- a/src/main/java/org/olat/repository/portlet/RepositoryPortletTableDataModel.java +++ b/src/main/java/org/olat/repository/portlet/RepositoryPortletTableDataModel.java @@ -25,7 +25,7 @@ import java.util.Locale; import org.olat.core.gui.control.generic.portal.PortletDefaultTableDataModel; import org.olat.core.gui.control.generic.portal.PortletEntry; import org.olat.core.util.filter.FilterFactory; -import org.olat.repository.RepositoryEntryLight; +import org.olat.repository.RepositoryEntry; /** * Description:<br> @@ -36,11 +36,11 @@ import org.olat.repository.RepositoryEntryLight; * Initial Date: 06.03.2009 <br> * @author gnaegi, rhaag */ -public class RepositoryPortletTableDataModel extends PortletDefaultTableDataModel<RepositoryEntryLight> { +public class RepositoryPortletTableDataModel extends PortletDefaultTableDataModel<RepositoryEntry> { /** * @see org.olat.core.gui.components.table.DefaultTableDataModel#getValueAt(int, int) */ - public RepositoryPortletTableDataModel(List<PortletEntry<RepositoryEntryLight>> objects, Locale locale) { + public RepositoryPortletTableDataModel(List<PortletEntry<RepositoryEntry>> objects, Locale locale) { super(objects, 3); super.setLocale(locale); } @@ -63,8 +63,8 @@ public class RepositoryPortletTableDataModel extends PortletDefaultTableDataMode } } - public RepositoryEntryLight getRepositoryEntry(int row) { - PortletEntry<RepositoryEntryLight> portletEntry = getObject(row); + public RepositoryEntry getRepositoryEntry(int row) { + PortletEntry<RepositoryEntry> portletEntry = getObject(row); return portletEntry.getValue(); } } diff --git a/src/main/java/org/olat/repository/ui/RepositoryFlexiTableModel.java b/src/main/java/org/olat/repository/ui/RepositoryFlexiTableModel.java index e79da6db02e91ccb9c69e710ea847371c2cad1e2..587088a7403289e307b8fbe06b87459c3d009c33 100644 --- a/src/main/java/org/olat/repository/ui/RepositoryFlexiTableModel.java +++ b/src/main/java/org/olat/repository/ui/RepositoryFlexiTableModel.java @@ -37,7 +37,7 @@ import org.olat.core.gui.translator.Translator; import org.olat.core.util.StringHelper; import org.olat.core.util.Util; import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryEntryStatus; +import org.olat.repository.RepositoryModule; import org.olat.repository.RepositoryService; import org.olat.repository.model.RepositoryEntryLifecycle; import org.olat.resource.accesscontrol.ACService; @@ -201,7 +201,7 @@ implements SortableFlexiTableDataModel<RepositoryEntry> { private String getDisplayName(RepositoryEntry repositoryEntry, Locale locale) { String displayName = repositoryEntry.getDisplayname(); if (repositoryEntry.getEntryStatus().decommissioned()) { - Translator pT = Util.createPackageTranslator(RepositoryEntryStatus.class, locale); + Translator pT = Util.createPackageTranslator(RepositoryModule.class, locale); displayName = "[" + pT.translate("title.prefix.closed") + "] ".concat(displayName); } return displayName; diff --git a/src/main/java/org/olat/repository/ui/RepositoryLifecycleAdminController.java b/src/main/java/org/olat/repository/ui/RepositoryLifecycleAdminController.java index f5a12ed6a3870b19271e97f151624c9dc008c787..60262480a24da454220f12c8dbe504b449653c1d 100644 --- a/src/main/java/org/olat/repository/ui/RepositoryLifecycleAdminController.java +++ b/src/main/java/org/olat/repository/ui/RepositoryLifecycleAdminController.java @@ -54,10 +54,10 @@ public class RepositoryLifecycleAdminController extends FormBasicController { RepositoryEntryLifeCycleUnit.month.name(), RepositoryEntryLifeCycleUnit.year.name() }; - private MultipleSelectionElement toCloseEl, toUnpublishEl, toDeleteEl; - private TextElement closeValueEl, unpublishValueEl, deleteValueEl; - private SingleSelection closeUnitEl, unpublishUnitEl, deleteUnitEl; - private FormLayoutContainer closeRuleCont, unpublishRuleCont, deleteRuleCont; + private MultipleSelectionElement toCloseEl, toDeleteEl; + private TextElement closeValueEl, deleteValueEl; + private SingleSelection closeUnitEl, deleteUnitEl; + private FormLayoutContainer closeRuleCont, deleteRuleCont; @Autowired private RepositoryModule repositoryModule; @@ -107,31 +107,6 @@ public class RepositoryLifecycleAdminController extends FormBasicController { closeUnitEl = uifactory.addDropdownSingleselect("clo-unit", null, closeRuleCont, unitKeys, unitValues, null); closeUnitEl.setDomReplacementWrapperRequired(false); selectUnitEl(closeUnitEl, autoCloseValue); - - RepositoryEntryLifeCycleValue autoUnpublishValue = repositoryModule.getLifecycleAutoUnpublishValue(); - String[] toUnpublishValues = new String[] { translate("change.to.unpublish.text") }; - toUnpublishEl = uifactory.addCheckboxesHorizontal("change.to.unpublish", formLayout, onKeys, toUnpublishValues); - toUnpublishEl.addActionListener(FormEvent.ONCHANGE); - if(autoUnpublishValue != null) { - toUnpublishEl.select(onKeys[0], true); - } - - unpublishRuleCont = FormLayoutContainer.createCustomFormLayout("unpublish.".concat(id), formLayout.getTranslator(), page); - unpublishRuleCont.setLabel(null, null); - unpublishRuleCont.setVisible(toUnpublishEl.isAtLeastSelected(1)); - unpublishRuleCont.contextPut("prefix", "unp"); - formLayout.add(unpublishRuleCont); - unpublishRuleCont.setRootForm(mainForm); - - String currentUnpublishValue = autoUnpublishValue == null ? null : Integer.toString(autoUnpublishValue.getValue()); - unpublishValueEl = uifactory.addTextElement("unp-value", null, 128, currentUnpublishValue, unpublishRuleCont); - unpublishValueEl.setDomReplacementWrapperRequired(false); - unpublishValueEl.setDisplaySize(3); - - unpublishUnitEl = uifactory.addDropdownSingleselect("unp-unit", null, unpublishRuleCont, unitKeys, unitValues, null); - unpublishUnitEl.setDomReplacementWrapperRequired(false); - selectUnitEl(unpublishUnitEl, autoUnpublishValue); - RepositoryEntryLifeCycleValue autoDeleteValue = repositoryModule.getLifecycleAutoDeleteValue(); String[] toDeleteValues = new String[] { translate("change.to.delete.text") }; @@ -186,30 +161,15 @@ public class RepositoryLifecycleAdminController extends FormBasicController { @Override protected boolean validateFormLogic(UserRequest ureq) { - boolean allOk = true; + boolean allOk = super.validateFormLogic(ureq); allOk &= validateFormLogic(toCloseEl, closeValueEl, closeUnitEl); - allOk &= validateFormLogic(toUnpublishEl, unpublishValueEl, unpublishUnitEl); allOk &= validateFormLogic(toDeleteEl, deleteValueEl, deleteUnitEl); RepositoryEntryLifeCycleValue autoClose = getValue(toCloseEl, closeValueEl, closeUnitEl); - RepositoryEntryLifeCycleValue autoUnpublish = getValue(toUnpublishEl, unpublishValueEl, unpublishUnitEl); RepositoryEntryLifeCycleValue autoDelete = getValue(toDeleteEl, deleteValueEl, deleteUnitEl); - - if(autoUnpublish != null && autoClose != null) { - if(autoUnpublish.compareTo(autoClose) <= 0) { - unpublishValueEl.setErrorKey("error.lifecycle.after", null); - allOk &= false; - } - } - + if(autoDelete != null) { - if(autoUnpublish != null) { - if(autoDelete.compareTo(autoUnpublish) <= 0) { - deleteValueEl.setErrorKey("error.lifecycle.after", null); - allOk &= false; - } - } if(autoClose != null) { if(autoDelete.compareTo(autoClose) <= 0) { deleteValueEl.setErrorKey("error.lifecycle.after", null); @@ -218,7 +178,7 @@ public class RepositoryLifecycleAdminController extends FormBasicController { } } - return allOk &= super.validateFormLogic(ureq); + return allOk; } protected boolean validateFormLogic(MultipleSelectionElement enableEl, TextElement textEl, SingleSelection unitEl) { @@ -254,8 +214,6 @@ public class RepositoryLifecycleAdminController extends FormBasicController { protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if(toCloseEl == source) { closeRuleCont.setVisible(toCloseEl.isAtLeastSelected(1)); - } else if(toUnpublishEl == source) { - unpublishRuleCont.setVisible(toUnpublishEl.isAtLeastSelected(1)); } else if(toDeleteEl == source) { deleteRuleCont.setVisible(toDeleteEl.isAtLeastSelected(1)); } @@ -265,8 +223,6 @@ public class RepositoryLifecycleAdminController extends FormBasicController { protected void formOK(UserRequest ureq) { String autoClose = getStringValue(toCloseEl, closeValueEl, closeUnitEl); repositoryModule.setLifecycleAutoClose(autoClose); - String autoUnpublish = getStringValue(toUnpublishEl, unpublishValueEl, unpublishUnitEl); - repositoryModule.setLifecycleAutoUnpublish(autoUnpublish); String autoDelete = getStringValue(toDeleteEl, deleteValueEl, deleteUnitEl); repositoryModule.setLifecycleAutoDelete(autoDelete); } diff --git a/src/main/java/org/olat/repository/ui/RepositoryTableModel.java b/src/main/java/org/olat/repository/ui/RepositoryTableModel.java index c84092548f681621db1e56fe47f41cc2ca2d23fe..dafe0a3b47b8b6b257f6de810e4a2e0db0e09a67 100644 --- a/src/main/java/org/olat/repository/ui/RepositoryTableModel.java +++ b/src/main/java/org/olat/repository/ui/RepositoryTableModel.java @@ -50,7 +50,6 @@ import org.olat.core.util.StringHelper; import org.olat.core.util.Util; import org.olat.login.LoginModule; import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryEntryStatus; import org.olat.repository.RepositoryEntryStatusEnum; import org.olat.repository.RepositoryModule; import org.olat.repository.RepositoryService; @@ -408,7 +407,7 @@ public class RepositoryTableModel extends DefaultTableDataModel<RepositoryEntry> private String getDisplayName(RepositoryEntry repositoryEntry, Locale locale) { String displayName = repositoryEntry.getDisplayname(); if (repositoryEntry.getEntryStatus().decommissioned()) { - Translator pT = Util.createPackageTranslator(RepositoryEntryStatus.class, locale); + Translator pT = Util.createPackageTranslator(RepositoryModule.class, locale); displayName = "[" + pT.translate("title.prefix.closed") + "] ".concat(displayName); } return displayName; diff --git a/src/main/java/org/olat/repository/ui/author/AccessRenderer.java b/src/main/java/org/olat/repository/ui/author/AccessRenderer.java index 2f5e2c23658b1d5291ae5b1ba1259399b4185e6f..13e77b0b9506fd16776a18f6b823ffe11ad59de1 100644 --- a/src/main/java/org/olat/repository/ui/author/AccessRenderer.java +++ b/src/main/java/org/olat/repository/ui/author/AccessRenderer.java @@ -66,34 +66,15 @@ public class AccessRenderer implements FlexiCellRenderer { private void render(StringOutput sb, RepositoryEntryStatusEnum status, boolean allUsers, boolean guests) { if(status == RepositoryEntryStatusEnum.trash || status == RepositoryEntryStatusEnum.deleted) { sb.append(translator.translate("table.header.access.deleted")); - } else if(!allUsers && !guests) { - sb.append(translator.translate("table.header.access.membersonly")); - } else { - //TODO repo access - /* - switch (access) { - case RepositoryEntry.ACC_OWNERS: - sb.append(translator.translate("table.header.access.owner")); - break; - case RepositoryEntry.ACC_OWNERS_AUTHORS: - sb.append(translator.translate("table.header.access.author")); - break; - case RepositoryEntry.ACC_USERS: - sb.append(translator.translate("table.header.access.user")); - break; - case RepositoryEntry.ACC_USERS_GUESTS: { - if(!guestLoginEnabled) { - sb.append(translator.translate("table.header.access.user")); - } else { - sb.append(translator.translate("table.header.access.guest")); - } - break; - } default: - // OLAT-6272 in case of broken repo entries with no access code - // return error instead of nothing - sb.append("ERROR"); + } else { + + sb.append(translator.translate("table.status.".concat(status.name()))); + if(allUsers) { + sb.append(translator.translate("table.allusers")); + } + if(guests && guestLoginEnabled) { + sb.append(translator.translate("table.guests")); } - */ } } } diff --git a/src/main/java/org/olat/repository/ui/author/AuthorListController.java b/src/main/java/org/olat/repository/ui/author/AuthorListController.java index f7713b939f5df083a74a7529d4734f97f6684b74..0688b0e8b1d144072c6cb170c98e74bd689a3fa9 100644 --- a/src/main/java/org/olat/repository/ui/author/AuthorListController.java +++ b/src/main/java/org/olat/repository/ui/author/AuthorListController.java @@ -415,10 +415,6 @@ public class AuthorListController extends FormBasicController implements Activat if(row.getEntryStatus() == RepositoryEntryStatusEnum.closed) { return "o_entry_closed"; } - /* - if(row.getRepositoryEntryStatus().isUnpublished()) {//TODO repo unpublished - return "o_entry_unpublished"; - }*/ return null; } diff --git a/src/main/java/org/olat/repository/ui/author/AuthoringEntryDataSource.java b/src/main/java/org/olat/repository/ui/author/AuthoringEntryDataSource.java index 12f1ba1c7c042c4fad1095024c9aed555ff11808..dc8a1e5eb5d6bc290af848c27b312c73a403057f 100644 --- a/src/main/java/org/olat/repository/ui/author/AuthoringEntryDataSource.java +++ b/src/main/java/org/olat/repository/ui/author/AuthoringEntryDataSource.java @@ -105,7 +105,7 @@ public class AuthoringEntryDataSource implements FlexiTableDataSourceDelegate<Au public final ResultInfos<AuthoringEntryRow> getRows(String query, List<FlexiTableFilter> filters, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) { - if(filters != null && filters.size() > 0) { + if(filters != null && !filters.isEmpty()) { String filter = filters.get(0).getFilter(); if(StringHelper.containsNonWhitespace(filter)) { searchParams.setResourceTypes(Collections.singletonList(filter)); @@ -132,7 +132,7 @@ public class AuthoringEntryDataSource implements FlexiTableDataSourceDelegate<Au List<AuthoringEntryRow> rows = processViewModel(views); ResultInfos<AuthoringEntryRow> results = new DefaultResultInfos<>(firstResult + rows.size(), -1, rows); if(firstResult == 0 && views.size() < maxResults) { - count = new Integer(views.size() ); + count = Integer.valueOf(views.size() ); } return results; } diff --git a/src/main/java/org/olat/repository/ui/author/wizard/UnpublishResourceCallback.java b/src/main/java/org/olat/repository/ui/author/wizard/UnpublishResourceCallback.java deleted file mode 100644 index 0b1776e1d0f4247e6f6be433820450437319edfd..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/ui/author/wizard/UnpublishResourceCallback.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * <a href="http://www.openolat.org"> - * OpenOLAT - Online Learning and Training</a><br> - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); <br> - * you may not use this file except in compliance with the License.<br> - * You may obtain a copy of the License at the - * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> - * <p> - * Unless required by applicable law or agreed to in writing,<br> - * software distributed under the License is distributed on an "AS IS" BASIS, <br> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> - * See the License for the specific language governing permissions and <br> - * limitations under the License. - * <p> - * Initial code contributed and copyrighted by<br> - * frentix GmbH, http://www.frentix.com - * <p> - */ -package org.olat.repository.ui.author.wizard; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; - -import org.olat.basesecurity.GroupRoles; -import org.olat.core.CoreSpringFactory; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.gui.UserRequest; -import org.olat.core.gui.control.WindowControl; -import org.olat.core.gui.control.generic.wizard.Step; -import org.olat.core.gui.control.generic.wizard.StepRunnerCallback; -import org.olat.core.gui.control.generic.wizard.StepsMainRunController; -import org.olat.core.gui.control.generic.wizard.StepsRunContext; -import org.olat.core.id.Identity; -import org.olat.core.id.Roles; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; -import org.olat.core.logging.activity.CourseLoggingAction; -import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; -import org.olat.core.util.mail.MailBundle; -import org.olat.core.util.mail.MailContext; -import org.olat.core.util.mail.MailContextImpl; -import org.olat.core.util.mail.MailHelper; -import org.olat.core.util.mail.MailManager; -import org.olat.core.util.mail.MailTemplate; -import org.olat.core.util.mail.MailerResult; -import org.olat.course.CourseFactory; -import org.olat.course.ICourse; -import org.olat.group.BusinessGroup; -import org.olat.group.BusinessGroupService; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryEntryRelationType; -import org.olat.repository.RepositoryEntryStatusEnum; -import org.olat.repository.RepositoryService; -import org.olat.repository.manager.CatalogManager; - -/** - * - * Initial date: 29.08.2014<br> - * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com - * - */ -public class UnpublishResourceCallback implements StepRunnerCallback { - - private static final OLog log = Tracing.createLoggerFor(UnpublishResourceCallback.class); - - private RepositoryEntry repositoryEntry; - - private final MailManager mailManager; - private final RepositoryService repositoryService; - private final BusinessGroupService businessGroupService; - - public UnpublishResourceCallback(RepositoryEntry entry) { - repositoryEntry = entry; - mailManager = CoreSpringFactory.getImpl(MailManager.class); - repositoryService = CoreSpringFactory.getImpl(RepositoryService.class); - businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); - } - - @Override - public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) { - - MailTemplate mailTemplate = (MailTemplate)runContext.get("mailTemplate"); - - if (mailTemplate != null) { - List<Identity> ownerList = new ArrayList<>(); - // owners - if (repositoryService.hasRoleExpanded(ureq.getIdentity(), repositoryEntry, GroupRoles.owner.name())) { - ownerList = repositoryService.getMembers(repositoryEntry, RepositoryEntryRelationType.all, GroupRoles.owner.name()); - } - - String businessPath = wControl.getBusinessControl().getAsString(); - MailContext context = new MailContextImpl(businessPath); - String metaId = UUID.randomUUID().toString().replace("-", ""); - MailerResult result = new MailerResult(); - MailBundle[] bundles = mailManager.makeMailBundles(context, ownerList, mailTemplate, ureq.getIdentity(), metaId, result); - result.append(mailManager.sendMessage(bundles)); - if (mailTemplate.getCpfrom()) { - MailBundle ccBundle = mailManager.makeMailBundle(context, ureq.getIdentity(), mailTemplate, ureq.getIdentity(), metaId, result); - result.append(mailManager.sendMessage(ccBundle)); - } - - StringBuilder errorMessage = new StringBuilder(1024); - StringBuilder warningMessage = new StringBuilder(1024); - Roles roles = ureq.getUserSession().getRoles(); - boolean detailedErrorOutput = roles.isAdministrator() || roles.isSystemAdmin(); - MailHelper.appendErrorsAndWarnings(result, errorMessage, warningMessage, detailedErrorOutput, ureq.getLocale()); - if (warningMessage.length() > 0) { - wControl.setWarning(warningMessage.toString()); - } - if (errorMessage.length() > 0) { - wControl.setError(errorMessage.toString()); - } - ownerList.clear(); - } - - //update status - repositoryEntry = repositoryService.loadByKey(repositoryEntry.getKey()); - //TODO repo access unpublish - repositoryEntry.setEntryStatus(RepositoryEntryStatusEnum.closed); - repositoryEntry = DBFactory.getInstance().getCurrentEntityManager().merge(repositoryEntry); - - // clean catalog - Object cleanCatalog = runContext.get("cleanCatalog"); - if(cleanCatalog != null && Boolean.TRUE.equals(cleanCatalog)) { - CoreSpringFactory.getImpl(CatalogManager.class).resourceableDeleted(repositoryEntry); - } - // clean groups - Object cleanGroups = runContext.get("cleanGroups"); - if(cleanGroups != null && Boolean.TRUE.equals(cleanGroups)) { - doCleanGroups(ureq.getIdentity()); - } - - - ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_EDITOR_CLOSE, getClass()); - log.audit("Repository entry " + repositoryEntry.getDisplayname() + " ( " + repositoryEntry.getOlatResource() + " ) closed"); - - return StepsMainRunController.DONE_MODIFIED; - } - - /** - * do unsubscribe all group members from this course - */ - private void doCleanGroups(Identity identity) { - ICourse course = CourseFactory.loadCourse(repositoryEntry); - if(course != null) { - // LearningGroups - List<BusinessGroup> allGroups = course.getCourseEnvironment().getCourseGroupManager().getAllBusinessGroups(); - for (BusinessGroup bGroup : allGroups) { - List<BusinessGroup> bGroupList = Collections.singletonList(bGroup); - List<RepositoryEntry> entries = businessGroupService.findRepositoryEntries(bGroupList, 0, -1); - if(entries.contains(repositoryEntry) && entries.size() == 1) { - List<Identity> owners = businessGroupService.getMembers(bGroup, GroupRoles.coach.name()); - businessGroupService.removeOwners(identity, owners, bGroup); - - List<Identity> participants = businessGroupService.getMembers(bGroup, GroupRoles.participant.name()); - businessGroupService.removeParticipants(identity, participants, bGroup, null); - - List<Identity> waitingList = businessGroupService.getMembers(bGroup, GroupRoles.waiting.name()); - businessGroupService.removeFromWaitingList(identity, waitingList, bGroup, null); - } else { - businessGroupService.removeResourceFrom(bGroupList, repositoryEntry); - } - } - repositoryService.removeMembers(repositoryEntry, GroupRoles.coach.name(), GroupRoles.participant.name()); - } - } -} \ No newline at end of file diff --git a/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_1_ExplanationStep.java b/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_1_ExplanationStep.java deleted file mode 100644 index 0d696e526d0ed8af5894eafc9704268208e2f72d..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_1_ExplanationStep.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * <a href="http://www.openolat.org"> - * OpenOLAT - Online Learning and Training</a><br> - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); <br> - * you may not use this file except in compliance with the License.<br> - * You may obtain a copy of the License at the - * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> - * <p> - * Unless required by applicable law or agreed to in writing,<br> - * software distributed under the License is distributed on an "AS IS" BASIS, <br> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> - * See the License for the specific language governing permissions and <br> - * limitations under the License. - * <p> - * Initial code contributed and copyrighted by<br> - * frentix GmbH, http://www.frentix.com - * <p> - */ -package org.olat.repository.ui.author.wizard; - -import org.olat.core.gui.UserRequest; -import org.olat.core.gui.components.form.flexible.FormItemContainer; -import org.olat.core.gui.components.form.flexible.impl.Form; -import org.olat.core.gui.control.Controller; -import org.olat.core.gui.control.WindowControl; -import org.olat.core.gui.control.generic.wizard.BasicStep; -import org.olat.core.gui.control.generic.wizard.PrevNextFinishConfig; -import org.olat.core.gui.control.generic.wizard.StepFormBasicController; -import org.olat.core.gui.control.generic.wizard.StepFormController; -import org.olat.core.gui.control.generic.wizard.StepsEvent; -import org.olat.core.gui.control.generic.wizard.StepsRunContext; -import org.olat.core.util.Util; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryService; - -/** - * - * Initial date: 29.08.2014<br> - * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com - * - */ -public class Unpublish_1_ExplanationStep extends BasicStep { - - public Unpublish_1_ExplanationStep(UserRequest ureq, RepositoryEntry entry ) { - super(ureq); - setTranslator(Util.createPackageTranslator(RepositoryService.class, getLocale(), getTranslator())); - setNextStep(new Unpublish_2_OptionsStep(ureq, entry)); - setI18nTitleAndDescr("close.ressource.step1", "close.ressource.step1"); - } - - @Override - public PrevNextFinishConfig getInitialPrevNextFinishConfig() { - return new PrevNextFinishConfig(false, true, false); - } - - @Override - public StepFormController getStepController(UserRequest ureq, WindowControl wControl, StepsRunContext runContext, Form form) { - return new ExplanationStepController(ureq, wControl, form, runContext); - } - - public class ExplanationStepController extends StepFormBasicController { - - public ExplanationStepController(UserRequest ureq, WindowControl wControl, - Form rootForm, StepsRunContext runContext) { - super(ureq, wControl, rootForm, runContext, LAYOUT_CUSTOM, "step1_wizard_close_resource"); - setTranslator(Util.createPackageTranslator(RepositoryService.class, getLocale(), getTranslator())); - initForm(ureq); - } - - @Override - protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { - // - } - - @Override - protected void doDispose() { - // - } - - @Override - protected void formOK(UserRequest ureq) { - fireEvent(ureq, StepsEvent.ACTIVATE_NEXT); - } - } -} \ No newline at end of file diff --git a/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_2_OptionsStep.java b/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_2_OptionsStep.java deleted file mode 100644 index 5145e7d643c92fd633d7b6d1054458c00fac308a..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_2_OptionsStep.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * <a href="http://www.openolat.org"> - * OpenOLAT - Online Learning and Training</a><br> - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); <br> - * you may not use this file except in compliance with the License.<br> - * You may obtain a copy of the License at the - * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> - * <p> - * Unless required by applicable law or agreed to in writing,<br> - * software distributed under the License is distributed on an "AS IS" BASIS, <br> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> - * See the License for the specific language governing permissions and <br> - * limitations under the License. - * <p> - * Initial code contributed and copyrighted by<br> - * frentix GmbH, http://www.frentix.com - * <p> - */ -package org.olat.repository.ui.author.wizard; - -import org.olat.core.gui.UserRequest; -import org.olat.core.gui.components.form.flexible.FormItemContainer; -import org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement; -import org.olat.core.gui.components.form.flexible.impl.Form; -import org.olat.core.gui.control.Controller; -import org.olat.core.gui.control.WindowControl; -import org.olat.core.gui.control.generic.wizard.BasicStep; -import org.olat.core.gui.control.generic.wizard.PrevNextFinishConfig; -import org.olat.core.gui.control.generic.wizard.StepFormBasicController; -import org.olat.core.gui.control.generic.wizard.StepFormController; -import org.olat.core.gui.control.generic.wizard.StepsEvent; -import org.olat.core.gui.control.generic.wizard.StepsRunContext; -import org.olat.core.util.Util; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryService; - -/** - * - * Options to clean-up groups and the catalog. - * - * Initial date: 29.08.2014<br> - * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com - * - */ -public class Unpublish_2_OptionsStep extends BasicStep { - - - public Unpublish_2_OptionsStep(UserRequest ureq, RepositoryEntry entry ) { - super(ureq); - setTranslator(Util.createPackageTranslator(RepositoryService.class, getLocale(), getTranslator())); - setNextStep(new Unpublish_3_SendMailStep(ureq, entry)); - setI18nTitleAndDescr("close.ressource.step2", "close.ressource.step2"); - } - - @Override - public PrevNextFinishConfig getInitialPrevNextFinishConfig() { - return new PrevNextFinishConfig(true, true, false); - } - - @Override - public StepFormController getStepController(UserRequest ureq, WindowControl wControl, StepsRunContext runContext, Form form) { - return new CloseRessourceOptionForm(ureq, wControl, form, runContext); - } - - public class CloseRessourceOptionForm extends StepFormBasicController { - - private MultipleSelectionElement checkboxClean; - - public CloseRessourceOptionForm(UserRequest ureq, WindowControl wControl, - Form rootForm, StepsRunContext runContext) { - super(ureq, wControl, rootForm, runContext, LAYOUT_DEFAULT, null); - setTranslator(Util.createPackageTranslator(RepositoryService.class, getLocale(), getTranslator())); - initForm(ureq); - } - - @Override - protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { - String[] keys = new String[] {"form.clean.catalog", "form.clean.groups"}; - String[] values = new String[] {translate("form.clean.catalog"), translate("form.clean.groups")}; - checkboxClean = uifactory.addCheckboxesVertical("form.clean.catalog", null, formLayout, keys, values, 1); - } - - @Override - protected void doDispose() { - // nothing to do - } - - @Override - protected void formOK(UserRequest ureq) { - boolean cleanCatalog = checkboxClean.isSelected(0); - boolean cleanGroups = checkboxClean.isSelected(1); - addToRunContext("cleanCatalog", new Boolean(cleanCatalog)); - addToRunContext("cleanGroups", new Boolean(cleanGroups)); - fireEvent(ureq, StepsEvent.ACTIVATE_NEXT); - } - } -} \ No newline at end of file diff --git a/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_3_SendMailStep.java b/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_3_SendMailStep.java deleted file mode 100644 index 1ac0387613a6541555ebfab1b3686b652f24badc..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/ui/author/wizard/Unpublish_3_SendMailStep.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * <a href="http://www.openolat.org"> - * OpenOLAT - Online Learning and Training</a><br> - * <p> - * Licensed under the Apache License, Version 2.0 (the "License"); <br> - * you may not use this file except in compliance with the License.<br> - * You may obtain a copy of the License at the - * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> - * <p> - * Unless required by applicable law or agreed to in writing,<br> - * software distributed under the License is distributed on an "AS IS" BASIS, <br> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> - * See the License for the specific language governing permissions and <br> - * limitations under the License. - * <p> - * Initial code contributed and copyrighted by<br> - * frentix GmbH, http://www.frentix.com - * <p> - */ -package org.olat.repository.ui.author.wizard; - -import org.apache.velocity.VelocityContext; -import org.olat.core.gui.UserRequest; -import org.olat.core.gui.components.form.flexible.FormItemContainer; -import org.olat.core.gui.components.form.flexible.impl.Form; -import org.olat.core.gui.control.Controller; -import org.olat.core.gui.control.WindowControl; -import org.olat.core.gui.control.generic.wizard.BasicStep; -import org.olat.core.gui.control.generic.wizard.PrevNextFinishConfig; -import org.olat.core.gui.control.generic.wizard.Step; -import org.olat.core.gui.control.generic.wizard.StepFormBasicController; -import org.olat.core.gui.control.generic.wizard.StepFormController; -import org.olat.core.gui.control.generic.wizard.StepsEvent; -import org.olat.core.gui.control.generic.wizard.StepsRunContext; -import org.olat.core.id.Identity; -import org.olat.core.id.UserConstants; -import org.olat.core.util.Util; -import org.olat.core.util.mail.MailTemplate; -import org.olat.core.util.mail.MailTemplateForm; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryService; - -/** - * - * Form to send the notification e-mails - * - * Initial date: 29.08.2014<br> - * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com - * - */ -public class Unpublish_3_SendMailStep extends BasicStep { - - private final RepositoryEntry entry; - - public Unpublish_3_SendMailStep(UserRequest ureq, RepositoryEntry entry) { - super(ureq); - setTranslator(Util.createPackageTranslator(RepositoryService.class, getLocale(), getTranslator())); - this.entry = entry; - setNextStep(Step.NOSTEP); - setI18nTitleAndDescr("close.ressource.step3", "close.ressource.step3"); - } - - @Override - public PrevNextFinishConfig getInitialPrevNextFinishConfig() { - return new PrevNextFinishConfig(true, false, true); - } - - @Override - public StepFormController getStepController(UserRequest ureq, WindowControl wControl, StepsRunContext runContext, Form form) { - return new SendMailStepController(ureq, wControl, form, runContext, entry); - } - - public class SendMailStepController extends StepFormBasicController { - private MailTemplate mailTemplate; - private MailTemplateForm templateForm; - - public SendMailStepController(UserRequest ureq, WindowControl wControl, - Form rootForm, StepsRunContext runContext, RepositoryEntry entry) { - super(ureq, wControl, rootForm, runContext, LAYOUT_BAREBONE, null); - setTranslator(Util.createPackageTranslator(RepositoryService.class, getLocale(), getTranslator())); - - String courseTitle = "'" + entry.getDisplayname() + "'"; - mailTemplate = createMailTemplate( - translate("wizard.step3.mail.subject", new String[] { courseTitle }), - translate("wizard.step3.mail.body", - new String[] { - courseTitle, - getIdentity().getUser().getProperty(UserConstants.FIRSTNAME, null) + " " - + getIdentity().getUser().getProperty(UserConstants.LASTNAME, null) - })); - - templateForm = new MailTemplateForm(ureq, wControl, mailTemplate, false, rootForm); - initForm(ureq); - } - - private MailTemplate createMailTemplate(String subject, String body) { - return new MailTemplate(subject, body, null) { - @Override - public void putVariablesInMailContext(VelocityContext context, Identity identity) { - // nothing to do - } - }; - } - - @Override - protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { - formLayout.add(templateForm.getInitialFormItem()); - } - - @Override - protected void doDispose() { - // - } - - @Override - protected void formOK(UserRequest ureq) { - if(templateForm.sendMailSwitchEnabled()) { - templateForm.updateTemplateFromForm(mailTemplate); - addToRunContext("mailTemplate", mailTemplate); - } - fireEvent(ureq, StepsEvent.ACTIVATE_NEXT); - } - } -} \ No newline at end of file diff --git a/src/main/java/org/olat/repository/ui/author/wizard/_content/step1_wizard_close_resource.html b/src/main/java/org/olat/repository/ui/author/wizard/_content/step1_wizard_close_resource.html deleted file mode 100644 index de2323801bf9b9075e86e7ce93a3700ee6b6bd8b..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/ui/author/wizard/_content/step1_wizard_close_resource.html +++ /dev/null @@ -1,19 +0,0 @@ -<h3>$r.translate("wizard.velocity.step1.par1")</h3> -<p>$r.translate("wizard.velocity.step1.par2")</p> -<p><strong>$r.translate("wizard.velocity.step1.par3")</strong></p> -<p> - <ul> - <li>$r.translate("wizard.velocity.step1.par3a")</li> - <li>$r.translate("wizard.velocity.step1.par3b")</li> - </ul> -</p> -<p><strong>$r.translate("wizard.velocity.step1.par4")</strong></p> -<p> - <ul> - <li>$r.translate("wizard.velocity.step1.par4a")</li> - <li>$r.translate("wizard.velocity.step1.par4b")</li> - <li>$r.translate("wizard.velocity.step1.par4c")</li> - <li>$r.translate("wizard.velocity.step1.par4d")</li> - <li>$r.translate("wizard.velocity.step1.par4e")</li> - </ul> -</p> diff --git a/src/main/java/org/olat/resource/accesscontrol/manager/ACFrontendManager.java b/src/main/java/org/olat/resource/accesscontrol/manager/ACFrontendManager.java index d7c6cd50540d318fb8e5a07725f16cecfd55a6c5..fb7f372941cbcb35b6913c4e3fdd058c67f88546 100644 --- a/src/main/java/org/olat/resource/accesscontrol/manager/ACFrontendManager.java +++ b/src/main/java/org/olat/resource/accesscontrol/manager/ACFrontendManager.java @@ -57,12 +57,11 @@ import org.olat.group.manager.BusinessGroupRelationDAO; import org.olat.group.model.EnrollState; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryEntryRef; -import org.olat.repository.RepositoryEntryShort; import org.olat.repository.RepositoryMailing; import org.olat.repository.RepositoryManager; import org.olat.repository.RepositoryService; +import org.olat.repository.manager.RepositoryEntryDAO; import org.olat.repository.manager.RepositoryEntryRelationDAO; -import org.olat.repository.model.RepositoryEntryShortImpl; import org.olat.resource.OLATResource; import org.olat.resource.OLATResourceManager; import org.olat.resource.accesscontrol.ACService; @@ -109,6 +108,8 @@ public class ACFrontendManager implements ACService, UserDataExportable { @Autowired private DB dbInstance; @Autowired + private RepositoryEntryDAO repositoryEntryDao; + @Autowired private RepositoryManager repositoryManager; @Autowired private RepositoryService repositoryService; @@ -498,7 +499,7 @@ public class ACFrontendManager implements ACService, UserDataExportable { return !result.isFailed(); } } else { - RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(resource, false); + RepositoryEntry entry = repositoryEntryDao.loadByResource(resource); if(entry != null) { if(!repositoryEntryRelationDao.hasRole(identity, entry, GroupRoles.participant.name())) { repositoryEntryRelationDao.addRole(identity, entry, GroupRoles.participant.name()); @@ -536,7 +537,7 @@ public class ACFrontendManager implements ACService, UserDataExportable { return true; } } else { - RepositoryEntryRef entry = repositoryManager.lookupRepositoryEntry(resource, false); + RepositoryEntryRef entry = repositoryEntryDao.loadByResource(resource); if(entry != null) { if(repositoryEntryRelationDao.hasRole(identity, entry, GroupRoles.participant.name())) { repositoryEntryRelationDao.removeRole(identity, entry, GroupRoles.participant.name()); @@ -556,7 +557,7 @@ public class ACFrontendManager implements ACService, UserDataExportable { return group.getName(); } } else { - RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(resource, false); + RepositoryEntry entry = repositoryEntryDao.loadByResource(resource); if(entry != null) { return entry.getDisplayname(); } @@ -599,12 +600,12 @@ public class ACFrontendManager implements ACService, UserDataExportable { } } if(!repositoryResources.isEmpty()) { - List<RepositoryEntryShort> repoEntries = repositoryManager.loadRepositoryEntryShorts(repositoryResources); - for(RepositoryEntryShort repoEntry:repoEntries) { + List<RepositoryEntry> repoEntries = repositoryEntryDao.loadByResources(repositoryResources); + for(RepositoryEntry repoEntry:repoEntries) { ACResourceInfoImpl info = new ACResourceInfoImpl(); info.setName(repoEntry.getDisplayname()); - info.setDescription(((RepositoryEntryShortImpl)repoEntry).getDescription()); - info.setResource(((RepositoryEntryShortImpl)repoEntry).getOlatResource()); + info.setDescription(repoEntry.getDescription()); + info.setResource(repoEntry.getOlatResource()); resourceInfos.add(info); } } diff --git a/src/main/java/org/olat/restapi/repository/RepositoryEntryWebService.java b/src/main/java/org/olat/restapi/repository/RepositoryEntryWebService.java index eea6906b04c65753533a68ae7357db11de13fa9d..647712a40f65cd3355eb1360065cc71dea520fc0 100644 --- a/src/main/java/org/olat/restapi/repository/RepositoryEntryWebService.java +++ b/src/main/java/org/olat/restapi/repository/RepositoryEntryWebService.java @@ -761,11 +761,6 @@ public class RepositoryEntryWebService { log.audit("REST unclosing course: " + entry.getDisplayname() + " [" + entry.getKey() + "]"); ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_UPDATE, getClass(), LoggingResourceable.wrap(entry, OlatResourceableType.genRepoEntry)); - } else if("unpublished".equals(newStatus)) { - repositoryService.unpublishRepositoryEntry(entry); - log.audit("REST unpublishing course: " + entry.getDisplayname() + " [" + entry.getKey() + "]"); - ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_DEACTIVATE, getClass(), - LoggingResourceable.wrap(entry, OlatResourceableType.genRepoEntry)); } else if("deleted".equals(newStatus)) { Identity identity = getIdentity(request); repositoryService.deleteSoftly(entry, identity, true); diff --git a/src/main/java/org/olat/restapi/repository/course/CourseWebService.java b/src/main/java/org/olat/restapi/repository/course/CourseWebService.java index b6e1fa8e9cf167004dca6ab6db8f05b3f9771abf..8799062365a59dd14ba2893c872e828f56fa0a08 100644 --- a/src/main/java/org/olat/restapi/repository/course/CourseWebService.java +++ b/src/main/java/org/olat/restapi/repository/course/CourseWebService.java @@ -398,11 +398,6 @@ public class CourseWebService { log.audit("REST unclosing course: " + re.getDisplayname() + " [" + re.getKey() + "]"); ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_UPDATE, getClass(), LoggingResourceable.wrap(re, OlatResourceableType.genRepoEntry)); - } else if("unpublished".equals(newStatus)) { - repositoryService.unpublishRepositoryEntry(re); - log.audit("REST unpublishing course: " + re.getDisplayname() + " [" + re.getKey() + "]"); - ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_DEACTIVATE, getClass(), - LoggingResourceable.wrap(re, OlatResourceableType.genRepoEntry)); } else if("deleted".equals(newStatus)) { Identity identity = getIdentity(request); repositoryService.deleteSoftly(re, identity, true); diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index ddf5e544b6f05bf149e74f1665f532878c430ba1..d3089c2db5efd2302f334614bb27b52fd89c33f8 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -25,7 +25,6 @@ <mapping-file>org/olat/basesecurity/NamedGroupImpl.hbm.xml</mapping-file> <mapping-file>org/olat/basesecurity/SecurityGroupImpl.hbm.xml</mapping-file> <mapping-file>org/olat/basesecurity/SecurityGroupMembershipImpl.hbm.xml</mapping-file> - <mapping-file>org/olat/repository/RepositoryEntry.hbm.xml</mapping-file> <mapping-file>org/olat/repository/model/CatalogEntryImpl.hbm.xml</mapping-file> <mapping-file>org/olat/course/nodes/projectbroker/datamodel/Project.hbm.xml</mapping-file> <mapping-file>org/olat/course/nodes/projectbroker/datamodel/ProjectBroker.hbm.xml</mapping-file> @@ -122,10 +121,10 @@ <class>org.olat.group.BusinessGroupImpl</class> <class>org.olat.registration.TemporaryKeyImpl</class> <class>org.olat.repository.RepositoryEntry</class> + <class>org.olat.repository.model.RepositoryEntryShortImpl</class> <class>org.olat.repository.model.RepositoryEntryToGroupRelation</class> <class>org.olat.repository.model.RepositoryEntryLifecycle</class> <class>org.olat.repository.model.RepositoryEntryStatistics</class> - <class>org.olat.repository.model.RepositoryEntryLightImpl</class> <class>org.olat.repository.model.RepositoryEntryMembership</class> <class>org.olat.repository.model.RepositoryEntryToOrganisationImpl</class> <class>org.olat.repository.model.RepositoryEntryToTaxonomyLevelImpl</class> diff --git a/src/test/java/org/olat/gatling/AccessTransactionGatling.java b/src/test/java/org/olat/gatling/AccessTransactionGatling.java index f57649df5022e57354f9c9194b187f3b96220635..84b927c4aa780f310f55e104c52a019a1964e594 100644 --- a/src/test/java/org/olat/gatling/AccessTransactionGatling.java +++ b/src/test/java/org/olat/gatling/AccessTransactionGatling.java @@ -69,7 +69,7 @@ public class AccessTransactionGatling extends OlatTestCase { sb.append("select v from repositoryentry as v ") .append(" inner join fetch v.olatResource as ores") .append(" inner join fetch v.statistics as statistics") - .append(" left join fetch v.lifecycle as lifecycle")//TODO repo access + .append(" left join fetch v.lifecycle as lifecycle") .append(" where ores.resName='CourseModule' and v.status ").in(RepositoryEntryStatusEnum.preparationToClosed()); List<RepositoryEntry> courses= dbInstance.getCurrentEntityManager() diff --git a/src/test/java/org/olat/repository/RepositoryManagerTest.java b/src/test/java/org/olat/repository/RepositoryManagerTest.java index b1373d77aa82858f9704b54be41005dfd54c81da..c0ca1d2def53557e54f2921bca1c3215402eae47 100644 --- a/src/test/java/org/olat/repository/RepositoryManagerTest.java +++ b/src/test/java/org/olat/repository/RepositoryManagerTest.java @@ -453,13 +453,13 @@ public class RepositoryManagerTest extends OlatTestCase { repositoryEntryRelationDao.addRole(id, re, GroupRoles.participant.name()); dbInstance.commitAndCloseSession(); - List<RepositoryEntryLight> entries = repositoryManager.getParticipantRepositoryEntry(id, -1, RepositoryEntryOrder.nameAsc); + List<RepositoryEntry> entries = repositoryManager.getParticipantRepositoryEntry(id, -1, RepositoryEntryOrder.nameAsc); Assert.assertNotNull(entries); Assert.assertFalse(entries.isEmpty()); boolean found = false; Set<Long> duplicates = new HashSet<Long>(); - for(RepositoryEntryLight entry:entries) { + for(RepositoryEntry entry:entries) { Assert.assertTrue(duplicates.add(entry.getKey())); if(entry.getKey().equals(re.getKey())) { found = true; @@ -488,13 +488,13 @@ public class RepositoryManagerTest extends OlatTestCase { businessGroupRelationDao.addRole(id, group, GroupRoles.participant.name()); dbInstance.commitAndCloseSession(); - List<RepositoryEntryLight> entries = repositoryManager.getParticipantRepositoryEntry(id, -1); + List<RepositoryEntry> entries = repositoryManager.getParticipantRepositoryEntry(id, -1); Assert.assertNotNull(entries); Assert.assertFalse(entries.isEmpty()); boolean found = false; Set<Long> duplicates = new HashSet<Long>(); - for(RepositoryEntryLight entry:entries) { + for(RepositoryEntry entry:entries) { Assert.assertTrue(duplicates.add(entry.getKey())); if(entry.getKey().equals(re.getKey())) { diff --git a/src/test/java/org/olat/repository/manager/AutomaticLifecycleServiceTest.java b/src/test/java/org/olat/repository/manager/AutomaticLifecycleServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..27151f532b4a626da8815883809dd6c055567f92 --- /dev/null +++ b/src/test/java/org/olat/repository/manager/AutomaticLifecycleServiceTest.java @@ -0,0 +1,55 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.repository.manager; + +import java.util.Date; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.olat.repository.RepositoryEntry; +import org.olat.test.OlatTestCase; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * This only check if the queries. Not the logic of the queries + * + * Initial date: 24 juil. 2018<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class AutomaticLifecycleServiceTest extends OlatTestCase { + + @Autowired + private AutomaticLifecycleService automaticLifecycleService; + + @Test + public void getRepositoryEntriesToDelete() { + List<RepositoryEntry> entriesToDelete = automaticLifecycleService.getRepositoryEntriesToDelete(new Date()); + Assert.assertNotNull(entriesToDelete); + } + + @Test + public void getRepositoryEntriesToClose() { + List<RepositoryEntry> entriesToClose = automaticLifecycleService.getRepositoryEntriesToClose(new Date()); + Assert.assertNotNull(entriesToClose); + } + +} diff --git a/src/test/java/org/olat/repository/manager/RepositoryEntryDAOTest.java b/src/test/java/org/olat/repository/manager/RepositoryEntryDAOTest.java index 3f78515098fadc883579890221b7882989ca3139..e4df2d0b91e8f858127469a7319695345e9825ac 100644 --- a/src/test/java/org/olat/repository/manager/RepositoryEntryDAOTest.java +++ b/src/test/java/org/olat/repository/manager/RepositoryEntryDAOTest.java @@ -29,6 +29,7 @@ import org.junit.Assert; import org.junit.Test; import org.olat.basesecurity.OrganisationService; import org.olat.core.commons.persistence.DB; +import org.olat.core.id.OLATResourceable; import org.olat.core.id.Organisation; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryEntryStatusEnum; @@ -108,6 +109,71 @@ public class RepositoryEntryDAOTest extends OlatTestCase { Assert.assertNotNull(emptyRes); Assert.assertEquals(0, emptyRes.size()); } + + @Test + public void loadByResource() { + Organisation defOrganisation = organisationService.getDefaultOrganisation(); + RepositoryEntry re = repositoryService.create(null, "Rei Ayanami", "-", "Repository entry DAO Test 12", "", null, + RepositoryEntryStatusEnum.trash, defOrganisation); + dbInstance.commitAndCloseSession(); + Assert.assertNotNull(re); + + RepositoryEntry loadedRe = repositoryEntryDao.loadByResource(re.getOlatResource()); + Assert.assertNotNull(loadedRe.getStatistics()); + Assert.assertEquals(re, loadedRe); + Assert.assertEquals(re.getOlatResource(), loadedRe.getOlatResource()); + } + + @Test + public void loadByResources() { + Organisation defOrganisation = organisationService.getDefaultOrganisation(); + RepositoryEntry re = repositoryService.create(null, "Rei Ayanami", "-", "Repository entry DAO Test 14", "", null, + RepositoryEntryStatusEnum.trash, defOrganisation); + dbInstance.commitAndCloseSession(); + Assert.assertNotNull(re); + + List<OLATResource> resources = Collections.singletonList(re.getOlatResource()); + List<RepositoryEntry> loadedRes = repositoryEntryDao.loadByResources(resources); + Assert.assertNotNull(loadedRes); + Assert.assertEquals(1, loadedRes.size()); + RepositoryEntry loadedRe = loadedRes.get(0); + Assert.assertNotNull(loadedRe.getStatistics()); + Assert.assertEquals(re, loadedRe); + Assert.assertEquals(re.getOlatResource(), loadedRe.getOlatResource()); + } + + @Test + public void loadByResourceId() { + Organisation defOrganisation = organisationService.getDefaultOrganisation(); + RepositoryEntry re = repositoryService.create(null, "Rei Ayanami", "-", "Repository entry DAO Test 10", "", null, + RepositoryEntryStatusEnum.trash, defOrganisation); + dbInstance.commitAndCloseSession(); + Assert.assertNotNull(re); + + OLATResourceable ores = re.getOlatResource(); + RepositoryEntry loadedRe = repositoryEntryDao.loadByResourceId(ores.getResourceableTypeName(), ores.getResourceableId()); + Assert.assertNotNull(loadedRe.getStatistics()); + Assert.assertEquals(re.getOlatResource(), loadedRe.getOlatResource()); + } + + @Test + public void loadByResourceIds() { + Organisation defOrganisation = organisationService.getDefaultOrganisation(); + RepositoryEntry re = repositoryService.create(null, "Rei Ayanami", "-", "Repository entry DAO Test 11", "", null, + RepositoryEntryStatusEnum.trash, defOrganisation); + dbInstance.commitAndCloseSession(); + Assert.assertNotNull(re); + + OLATResourceable ores = re.getOlatResource(); + Collection<Long> oresIds = Collections.singletonList(ores.getResourceableId()); + List<RepositoryEntry> loadedRes = repositoryEntryDao.loadByResourceIds(ores.getResourceableTypeName(), oresIds); + Assert.assertNotNull(loadedRes); + Assert.assertEquals(1, loadedRes.size()); + RepositoryEntry loadedRe = loadedRes.get(0); + Assert.assertEquals(re, loadedRe); + Assert.assertEquals(re.getOlatResource(), loadedRe.getOlatResource()); + Assert.assertNotNull(loadedRe.getStatistics()); + } @Test public void searchByIdAndRefs() { @@ -268,4 +334,7 @@ public class RepositoryEntryDAOTest extends OlatTestCase { Assert.assertNotNull(emptyRes); Assert.assertEquals(0, emptyRes.size()); } + + + } \ No newline at end of file diff --git a/src/test/java/org/olat/resource/accesscontrol/ACFrontendManagerTest.java b/src/test/java/org/olat/resource/accesscontrol/ACFrontendManagerTest.java index 04e01a94bd8379cdb0526b7baa45bd5bb3b7bdb7..a0027941e8dde7f12151d0f9fa8803cfa799d8d4 100644 --- a/src/test/java/org/olat/resource/accesscontrol/ACFrontendManagerTest.java +++ b/src/test/java/org/olat/resource/accesscontrol/ACFrontendManagerTest.java @@ -409,7 +409,6 @@ public class ACFrontendManagerTest extends OlatTestCase { RepositoryEntry re = repositoryService.create(null, "Florian Gnägi", "Access controlled by OLAT ", "JunitRE" + UUID.randomUUID().toString().replace("-", ""), "Description", r, RepositoryEntryStatusEnum.review, defOrganisation); - //TODO repo re.setAccess(RepositoryEntry.ACC_OWNERS_AUTHORS); re = repositoryService.update(re); dbInstance.commitAndCloseSession(); return re; diff --git a/src/test/java/org/olat/test/AllTestsJunit4.java b/src/test/java/org/olat/test/AllTestsJunit4.java index f8ca81a48d59df946f1ba77fd02ddd8402f2b76c..040438731ce31a2349297fc718934439992d7421 100644 --- a/src/test/java/org/olat/test/AllTestsJunit4.java +++ b/src/test/java/org/olat/test/AllTestsJunit4.java @@ -135,6 +135,7 @@ import org.junit.runners.Suite; org.olat.user.UserNameAndPasswordSyntaxCheckerWithRegexpTest.class, org.olat.user.manager.UserDataExportDAOTest.class, org.olat.user.manager.UserDataExportServiceTest.class, + org.olat.repository.manager.AutomaticLifecycleServiceTest.class, org.olat.repository.manager.RepositoryEntryDAOTest.class, org.olat.repository.manager.RepositoryEntryLifecycleDAOTest.class, org.olat.repository.manager.RepositoryEntryRelationDAOTest.class,