CCM NG: Several small bug fixes
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5169 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
a4be55e4d3
commit
42b715036f
|
|
@ -30,6 +30,7 @@ import org.libreccm.l10n.GlobalizationHelper;
|
|||
import org.libreccm.security.User;
|
||||
import org.libreccm.workflow.Task;
|
||||
import org.libreccm.workflow.TaskManager;
|
||||
import org.libreccm.workflow.TaskState;
|
||||
import org.libreccm.workflow.Workflow;
|
||||
import org.libreccm.workflow.WorkflowManager;
|
||||
import org.libreccm.workflow.WorkflowRepository;
|
||||
|
|
@ -53,6 +54,7 @@ import java.io.Serializable;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
|
|
@ -222,6 +224,30 @@ class ItemLifecycleAdminController implements Serializable {
|
|||
ContentItemPage.PUBLISHING_TAB);
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void repulish(final ContentItem item) {
|
||||
|
||||
Objects.requireNonNull(item);
|
||||
|
||||
final Optional<ContentItem> liveItem = itemManager
|
||||
.getLiveVersion(item, ContentItem.class);
|
||||
if (liveItem.isPresent()) {
|
||||
final ContentItem contentItem = itemRepo
|
||||
.findById(item.getObjectId())
|
||||
.orElseThrow(() -> new IllegalArgumentException(String
|
||||
.format("No ContentItem with Id %d in the database.",
|
||||
item.getObjectId())));
|
||||
itemManager.publish(contentItem);
|
||||
final Workflow workflow = contentItem.getWorkflow();
|
||||
if (workflow != null
|
||||
&& workflow.isActive()
|
||||
&& workflow.getTasksState() == TaskState.ENABLED) {
|
||||
|
||||
workflowManager.finish(contentItem.getWorkflow());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void publish(final String itemUuid,
|
||||
final long cycleDefId,
|
||||
|
|
|
|||
|
|
@ -293,15 +293,12 @@ class ItemLifecycleItemPane extends BaseItemPane {
|
|||
private static void republish(final ContentItem item,
|
||||
final boolean reset,
|
||||
final User user) {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ContentItemManager itemManager = cdiUtil.findBean(
|
||||
ContentItemManager.class);
|
||||
final WorkflowManager workflowManager = cdiUtil.findBean(
|
||||
WorkflowManager.class);
|
||||
|
||||
itemManager.publish(item);
|
||||
|
||||
workflowManager.finish(item.getWorkflow());
|
||||
final ItemLifecycleAdminController controller = cdiUtil
|
||||
.findBean(ItemLifecycleAdminController.class);
|
||||
|
||||
controller.repulish(item);
|
||||
}
|
||||
|
||||
private class RepublishLink extends PublishLink {
|
||||
|
|
|
|||
|
|
@ -312,6 +312,7 @@ import static org.librecms.CmsConstants.*;
|
|||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
||||
+ "AND i.displayName = :name "
|
||||
+ "AND i.version = 'DRAFT' "
|
||||
+ "AND ("
|
||||
+ " ("
|
||||
+ " p.grantee IN :roles "
|
||||
|
|
@ -334,6 +335,7 @@ import static org.librecms.CmsConstants.*;
|
|||
+ "WHERE c.category = :folder "
|
||||
+ "AND c.type = '" + CATEGORIZATION_TYPE_FOLDER + "' "
|
||||
+ "AND i.displayName = :name "
|
||||
+ "AND i.version = 'DRAFT'"
|
||||
+ "AND ("
|
||||
+ " ("
|
||||
+ " p.grantee IN :roles "
|
||||
|
|
|
|||
|
|
@ -97,12 +97,14 @@ public class PagesRepository extends AbstractEntityRepository<Long, Pages> {
|
|||
}
|
||||
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public void save(final Pages pages) {
|
||||
super.save(pages);
|
||||
}
|
||||
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public void delete(final Pages pages) {
|
||||
super.delete(pages);
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ public class PagesRouter {
|
|||
}
|
||||
|
||||
@GET
|
||||
@Path("/{name[\\w\\-]+}.{lang:\\w+}.json")
|
||||
@Path("/{name:[\\w\\-]+}.{lang:\\w+}.json")
|
||||
@Produces("text/json")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public String getRootPageAsJson(
|
||||
|
|
|
|||
|
|
@ -503,3 +503,5 @@ cms.ui.pages.pagemodels.index_page=Index Page Model
|
|||
cms.ui.pages.pagemodels.item_page=Item Page Model
|
||||
cms.ui.pages.pagemodels.save=Save
|
||||
cms.ui.pages.pagemodels.cancel=Cancel
|
||||
cms.ui.cateogry.is_visible=Is visible?
|
||||
cms.ui.category.cantmoved=This category can't be moved.
|
||||
|
|
|
|||
|
|
@ -500,3 +500,5 @@ cms.ui.pages.pagemodels.index_page=Index Page Model
|
|||
cms.ui.pages.pagemodels.item_page=Item Page Model
|
||||
cms.ui.pages.pagemodels.save=Speichern
|
||||
cms.ui.pages.pagemodels.cancel=Abbrechen
|
||||
cms.ui.cateogry.is_visible=Sichtbar?
|
||||
cms.ui.category.cantmoved=Diese Kategorie kann nicht verschoben werden.
|
||||
|
|
|
|||
|
|
@ -459,3 +459,6 @@ cms.ui.pages.pagemodels.index_page=Index Page Model
|
|||
cms.ui.pages.pagemodels.item_page=Item Page Model
|
||||
cms.ui.pages.pagemodels.save=Save
|
||||
cms.ui.pages.pagemodels.cancel=Cancel
|
||||
cms.ui.cateogry.is_visible=Is visible?
|
||||
cms.ui.category.cantmoved=This category can't be moved.
|
||||
cms.ui.category.localization_none=No localization available
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ import java.util.UUID;
|
|||
@RequestScoped
|
||||
public class CategoryRepository extends AbstractEntityRepository<Long, Category> {
|
||||
|
||||
private static final long serialVersionUID = 8848653913581241248L;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(
|
||||
CategoryRepository.class);
|
||||
|
||||
|
|
@ -97,7 +99,7 @@ public class CategoryRepository extends AbstractEntityRepository<Long, Category>
|
|||
*/
|
||||
public Optional<Category> findByUuid(final String uuid) {
|
||||
final TypedQuery<Category> query = getEntityManager().
|
||||
createNamedQuery("Category.findByUuid", Category.class);
|
||||
createNamedQuery("Category.findByUuid", Category.class);
|
||||
query.setParameter("uuid", uuid);
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.arsdigita.kernel.KernelConfig;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
|
@ -36,7 +37,9 @@ import java.util.Enumeration;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -102,6 +105,8 @@ public class GlobalizationHelper implements Serializable {
|
|||
public String getValueFromLocalizedString(
|
||||
final LocalizedString localizedString) {
|
||||
|
||||
Objects.requireNonNull(localizedString);
|
||||
|
||||
if (localizedString.hasValue(getNegotiatedLocale())) {
|
||||
return localizedString.getValue(getNegotiatedLocale());
|
||||
}
|
||||
|
|
@ -131,6 +136,29 @@ public class GlobalizationHelper implements Serializable {
|
|||
.getValue();
|
||||
}
|
||||
|
||||
public String getValueFromLocalizedString(
|
||||
final LocalizedString localizedString,
|
||||
final Callable<String> fallbackProvider) {
|
||||
|
||||
Objects.requireNonNull(localizedString);
|
||||
Objects.requireNonNull(fallbackProvider);
|
||||
|
||||
final KernelConfig kernelConfig = confManager
|
||||
.findConfiguration(KernelConfig.class);
|
||||
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||
if (localizedString.hasValue(getNegotiatedLocale())
|
||||
|| localizedString.hasValue(defaultLocale)) {
|
||||
|
||||
return getValueFromLocalizedString(localizedString);
|
||||
} else {
|
||||
try {
|
||||
return fallbackProvider.call();
|
||||
} catch (Exception ex) {
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Locale getNegotiatedLocale() {
|
||||
|
||||
final KernelConfig kernelConfig = confManager.findConfiguration(
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
xmlns:foundry="http://foundry.libreccm.org"
|
||||
xmlns:nav="http://ccm.redhat.com/navigation"
|
||||
exclude-result-prefixes="xsl bebop cms foundry nav"
|
||||
version="1.0">
|
||||
version="2.0">
|
||||
|
||||
<!-- DE Benutze DHTML-Editor (HTMLArea) -->
|
||||
<!-- EN Use DHTML-Editor (HTMLArea) -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue