- Removed class WorkflowTemplate, replaced by property abstractWorkflow in class workflow
- Fixed several test failures



git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5015 8810af33-2d31-482b-a856-94f89814c4df

Former-commit-id: e4bbfc3e41
pull/2/head
jensp 2017-09-27 19:45:02 +00:00
parent 6ba2869181
commit b6c1253bfe
54 changed files with 5950 additions and 2360 deletions

View File

@ -23,8 +23,7 @@ import org.libreccm.workflow.AssignableTask;
import org.libreccm.workflow.AssignableTaskManager;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowManager;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionRepository;
@ -56,7 +55,7 @@ class ApplyWorkflowController {
private ContentSectionRepository sectionRepo;
@Inject
private WorkflowTemplateRepository templateRepo;
private WorkflowRepository templateRepo;
@Inject
private WorkflowManager workflowManager;
@ -68,7 +67,7 @@ class ApplyWorkflowController {
private PermissionChecker permissionChecker;
@Transactional(Transactional.TxType.REQUIRED)
protected WorkflowTemplate getDefaultWorkflow(final ContentType contentType) {
protected Workflow getDefaultWorkflow(final ContentType contentType) {
Objects.requireNonNull(contentType);
@ -83,7 +82,7 @@ class ApplyWorkflowController {
@Transactional(Transactional.TxType.REQUIRED)
Long getDefaultWorkflowId(final ContentType contentType) {
final WorkflowTemplate workflowTemplate
final Workflow workflowTemplate
= getDefaultWorkflow(contentType);
if (workflowTemplate == null) {
return null;
@ -93,7 +92,7 @@ class ApplyWorkflowController {
}
@Transactional(Transactional.TxType.REQUIRED)
protected List<WorkflowTemplate> getWorkflowTemplates(
protected List<Workflow> getWorkflowTemplates(
final ContentSection section) {
final ContentSection contentSection = sectionRepo
@ -115,7 +114,7 @@ class ApplyWorkflowController {
Objects.requireNonNull(folder);
Objects.requireNonNull(workflowTemplateId);
final WorkflowTemplate workflowTemplate;
final Workflow workflowTemplate;
if (workflowTemplateId == null
&& permissionChecker
.isPermitted(ItemPrivileges.APPLY_ALTERNATE_WORKFLOW, folder)) {

View File

@ -43,7 +43,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.PermissionChecker;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.CmsConstants;
import org.librecms.contentsection.privileges.ItemPrivileges;
@ -111,7 +111,7 @@ public class ApplyWorkflowFormSection
LOGGER.error("Too many listeners", ex);
}
add(new Label(new GlobalizedMessage("cms.ui.authoring.workflow",
super.add(new Label(new GlobalizedMessage("cms.ui.authoring.workflow",
CmsConstants.CMS_BUNDLE)));
radioGroup.addValidationListener(new NotNullValidationListener() {
@ -125,8 +125,8 @@ public class ApplyWorkflowFormSection
}
});
add(radioGroup);
addInitListener(this);
super.add(radioGroup);
super.addInitListener(this);
}
/**
@ -280,7 +280,7 @@ public class ApplyWorkflowFormSection
}
@Override
protected List<WorkflowTemplate> getCollection(final PageState state) {
protected List<Workflow> getCollection(final PageState state) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ApplyWorkflowController controller = cdiUtil
.findBean(ApplyWorkflowController.class);

View File

@ -21,7 +21,6 @@ package com.arsdigita.cms.ui.authoring;
import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.FormSection;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
@ -38,16 +37,13 @@ import org.librecms.contentsection.Folder;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.util.Assert;
import org.arsdigita.cms.CMSConfig;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItemInitializer;
import org.librecms.contentsection.ContentItemManager;
import org.librecms.contentsection.ContentType;
import java.util.Date;
@ -293,7 +289,7 @@ public abstract class BasicPageForm extends BasicItemForm {
final String name,
final ContentSection section,
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Workflow workflowTemplate,
final ContentItemInitializer<T> initializer,
final Locale locale) throws FormProcessException {

View File

@ -18,8 +18,8 @@
*/
package com.arsdigita.cms.ui.authoring;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemInitializer;
import org.librecms.contentsection.ContentItemManager;
@ -56,7 +56,7 @@ class BasicPageFormController {
private FolderRepository folderRepo;
@Inject
private WorkflowTemplateRepository workflowTemplateRepo;
private WorkflowRepository workflowRepo;
@Transactional(Transactional.TxType.REQUIRED)
protected <T extends ContentItem> T createContentItem(
@ -81,7 +81,7 @@ class BasicPageFormController {
final String name,
final ContentSection section,
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Workflow workflowTemplate,
final Class<T> clazz,
final ContentItemInitializer<T> initializer,
final Locale locale) {
@ -109,7 +109,7 @@ class BasicPageFormController {
locale);
} else {
final WorkflowTemplate itemWorkflowTemplate = workflowTemplateRepo
final Workflow itemWorkflowTemplate = workflowRepo
.findById(workflowTemplate.getWorkflowId())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No WorkflowTemplate with ID %d in the database.",

View File

@ -39,8 +39,8 @@ import com.arsdigita.util.Assert;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemInitializer;
@ -100,9 +100,9 @@ public class PageCreateForm
this.selectedLanguageParam = selectedLanguageParam;
workflowSection.setCreationSelector(creationSelector);
addSubmissionListener(this);
super.addSubmissionListener(this);
getSaveCancelSection().getSaveButton()
super.getSaveCancelSection().getSaveButton()
.setButtonLabel(new GlobalizedMessage("cms.ui.create",
CmsConstants.CMS_BUNDLE));
}
@ -239,9 +239,9 @@ public class PageCreateForm
getItemInitializer(data, state),
locale);
} else {
final WorkflowTemplateRepository workflowTemplateRepo = cdiUtil
.findBean(WorkflowTemplateRepository.class);
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final WorkflowRepository workflowRepo = cdiUtil
.findBean(WorkflowRepository.class);
final Workflow workflowTemplate = workflowRepo
.findById(selectedWorkflowTemplateId)
.orElseThrow(() -> new IllegalArgumentException(String.format(
"No WorkflowTemplate with ID %d in the database.",
@ -262,7 +262,7 @@ public class PageCreateForm
final ContentItemRepository itemRepo = cdiUtil
.findBean(ContentItemRepository.class);
itemRepo.save(item);
state.setValue(selectedLanguageParam, locale.toString());
creationSelector.editItem(state, item);

View File

@ -64,7 +64,6 @@ import org.libreccm.workflow.TaskManager;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowManager;
import org.libreccm.workflow.WorkflowRepository;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemManager;
@ -823,7 +822,7 @@ class ItemLifecycleSelectForm extends BaseForm {
} else {
// restart the workflow by recreating it
// from the same workflow template
final WorkflowTemplate template = workflow.getTemplate();
final Workflow template = workflow.getTemplate();
workflowRepo.delete(workflow);
final Workflow restarted = workflowManager.createWorkflow(
template, item);

View File

@ -18,7 +18,7 @@
*/
package com.arsdigita.cms.ui.type;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionRepository;
import org.librecms.contentsection.ContentType;
@ -130,7 +130,7 @@ class ContentTypeAdminPaneController {
}
@Transactional(Transactional.TxType.REQUIRED)
public WorkflowTemplate getWorkflowTemplate(final ContentType type) {
public Workflow getWorkflowTemplate(final ContentType type) {
final ContentType contentType = typeRepo
.findById(type.getObjectId())
@ -146,7 +146,7 @@ class ContentTypeAdminPaneController {
public Optional<String> getWorkflowTemplateName(final ContentType type,
final Locale locale) {
final WorkflowTemplate workflowTemplate = getWorkflowTemplate(type);
final Workflow workflowTemplate = getWorkflowTemplate(type);
if (workflowTemplate == null) {
return Optional.empty();
@ -170,7 +170,7 @@ class ContentTypeAdminPaneController {
}
@Transactional(Transactional.TxType.REQUIRED)
public List<WorkflowTemplate> getWorkflowTemplates(
public List<Workflow> getWorkflowTemplates(
final ContentSection section) {
final ContentSection contentSection = sectionRepo

View File

@ -23,7 +23,6 @@ import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.lifecycle.LifecycleDefinition;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig;
@ -34,7 +33,6 @@ import org.libreccm.cdi.utils.CdiUtil;
import java.util.Locale;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.CmsConstants;
import org.librecms.contenttypes.ContentTypeInfo;
import org.librecms.contenttypes.ContentTypesManager;

View File

@ -42,10 +42,8 @@ import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.lifecycle.LifecycleDefinition;
import org.libreccm.workflow.WorkflowTemplate;
import com.arsdigita.cms.ui.CMSForm;
import com.arsdigita.cms.ui.GlobalNavigation;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.util.UncheckedWrapperException;
@ -53,7 +51,8 @@ import com.arsdigita.util.UncheckedWrapperException;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentTypeManager;
import org.librecms.contentsection.ContentTypeRepository;
@ -204,7 +203,7 @@ public class EditType extends CMSForm
data.put(m_lcSelect.getName(), cycle.getDefinitionId());
}
WorkflowTemplate template = type.getDefaultWorkflow();
Workflow template = type.getDefaultWorkflow();
if (template != null) {
data.put(m_wfSelect.getName(), template.getWorkflowId());
}
@ -215,7 +214,7 @@ public class EditType extends CMSForm
* model.
*/
private ContentType getContentType(final PageState state) {
final String key = (String) m_types.getSelectedKey(state);
final String key = m_types.getSelectedKey(state);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentTypeRepository typeRepo = cdiUtil.findBean(
@ -226,7 +225,7 @@ public class EditType extends CMSForm
result = typeRepo.findById(Long.parseLong(key));
} catch (NumberFormatException ex) {
throw new UncheckedWrapperException(String.format(
"The provided key \"%d\" is not a long.", key),
"The provided key \"%s\" is not a long.", key),
ex);
}
@ -265,8 +264,8 @@ public class EditType extends CMSForm
ContentTypeRepository.class);
final LifecycleDefinitionRepository lifecycleDefRepo = cdiUtil.findBean(
LifecycleDefinitionRepository.class);
final WorkflowTemplateRepository workflowTemplateRepo = cdiUtil
.findBean(WorkflowTemplateRepository.class);
final WorkflowRepository workflowRepo = cdiUtil
.findBean(WorkflowRepository.class);
final ContentTypeManager typeManager = cdiUtil.findBean(
ContentTypeManager.class);
@ -292,11 +291,11 @@ public class EditType extends CMSForm
} else {
defaultLifecycle = lifecycleDefRepo.findById(lifecycleId).get();
}
final WorkflowTemplate defaultWorkflow;
final Workflow defaultWorkflow;
if (workflowId == 0) {
defaultWorkflow = null;
} else {
defaultWorkflow = workflowTemplateRepo.findById(workflowId).get();
defaultWorkflow = workflowRepo.findById(workflowId).get();
}
@ -367,7 +366,7 @@ public class EditType extends CMSForm
final ContentTypeAdminPaneController controller = cdiUtil
.findBean(ContentTypeAdminPaneController.class);
final List<WorkflowTemplate> templates = controller
final List<Workflow> templates = controller
.getWorkflowTemplates(section);
final Locale defaultLocale = KernelConfig.getConfig()
.getDefaultLocale();

View File

@ -30,16 +30,19 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ui.CMSForm;
import com.arsdigita.web.Web;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowTemplate;
import org.apache.logging.log4j.Logger;
import java.math.BigDecimal;
import java.util.TooManyListenersException;
import org.apache.logging.log4j.LogManager;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.WorkflowManager;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.ContentItem;
/**
@ -97,12 +100,13 @@ class ItemWorkflowSelectForm extends CMSForm {
if (item.getWorkflow() == null) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowTemplateRepository templateRepo = cdiUtil.
findBean(WorkflowTemplateRepository.class);
final WorkflowRepository templateRepo = cdiUtil.
findBean(WorkflowRepository.class);
final WorkflowManager workflowManager = cdiUtil.findBean(
WorkflowManager.class);
final WorkflowTemplate template = templateRepo.findById(flowId)
final Workflow template = templateRepo
.findById(flowId)
.get();
workflowManager.createWorkflow(template, item);
}

View File

@ -25,8 +25,8 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.cms.CMS;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.Workflow;
/**
* @author Uday Mathur
@ -60,28 +60,8 @@ class WorkflowAddForm extends BaseWorkflowForm {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowAdminPaneController controller = cdiUtil.findBean(
WorkflowAdminPaneController.class);
// final WorkflowTemplateRepository workflowTemplateRepository
// = cdiUtil.findBean(
// WorkflowTemplateRepository.class);
// final ContentSectionManager sectionManager = cdiUtil.findBean(
// ContentSectionManager.class);
// final ConfigurationManager confManager = cdiUtil.findBean(
// ConfigurationManager.class);
// final KernelConfig kernelConfig = confManager.findConfiguration(
// KernelConfig.class);
// final Locale defaultLocale = kernelConfig.getDefaultLocale();
//
// final WorkflowTemplate workflow = new WorkflowTemplate();
// workflow.getName().addValue(defaultLocale, label);
// workflow.getDescription().addValue(defaultLocale, description);
//
// workflowTemplateRepository.save(workflow);
//
// final ContentSection section = CMS.getContext().getContentSection();
// sectionManager
// .addWorkflowTemplateToContentSection(workflow, section);
final WorkflowTemplate workflow = controller.createWorkflow(
final Workflow workflow = controller.createWorkflow(
CMS.getContext().getContentSection(),
label,
description);

View File

@ -29,7 +29,6 @@ import com.arsdigita.cms.ui.VisibilityComponent;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.librecms.contentsection.privileges.AdminPrivileges;
@ -92,8 +91,8 @@ public final class WorkflowAdminPane extends BaseAdminPane {
.toString();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowTemplateRepository templateRepo = cdiUtil.findBean(
WorkflowTemplateRepository.class);
final WorkflowRepository templateRepo = cdiUtil.findBean(
WorkflowRepository.class);
return templateRepo.findById(Long.parseLong(id));
}

View File

@ -35,8 +35,6 @@ import org.libreccm.workflow.TaskManager;
import org.libreccm.workflow.TaskRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionManager;
import org.librecms.contentsection.ContentSectionRepository;
@ -54,7 +52,6 @@ import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.management.relation.RoleInfo;
import javax.transaction.Transactional;
/**
@ -79,9 +76,6 @@ public class WorkflowAdminPaneController {
@Inject
private WorkflowRepository workflowRepo;
@Inject
private WorkflowTemplateRepository workflowTemplateRepo;
@Inject
private TaskRepository taskRepo;
@ -95,7 +89,7 @@ public class WorkflowAdminPaneController {
private RoleRepository roleRepo;
@Transactional(Transactional.TxType.REQUIRED)
public List<WorkflowTemplate> retrieveWorkflows(final ContentSection section) {
public List<Workflow> retrieveWorkflows(final ContentSection section) {
final ContentSection contentSection = sectionRepo
.findById(section.getObjectId())
@ -108,9 +102,9 @@ public class WorkflowAdminPaneController {
}
@Transactional(Transactional.TxType.REQUIRED)
public WorkflowTemplate createWorkflow(final ContentSection section,
final String name,
final String desc) {
public Workflow createWorkflow(final ContentSection section,
final String name,
final String desc) {
final KernelConfig kernelConfig = confManager.findConfiguration(
KernelConfig.class);
@ -123,11 +117,12 @@ public class WorkflowAdminPaneController {
+ "Where did that ID come from?",
section.getObjectId())));
final WorkflowTemplate workflowTemplate = new WorkflowTemplate();
final Workflow workflowTemplate = new Workflow();
workflowTemplate.setAbstractWorkflow(true);
workflowTemplate.getName().addValue(defaultLocale, name);
workflowTemplate.getDescription().addValue(defaultLocale, desc);
workflowTemplateRepo.save(workflowTemplate);
workflowRepo.save(workflowTemplate);
sectionManager.addWorkflowTemplateToContentSection(workflowTemplate,
contentSection);
@ -355,38 +350,38 @@ public class WorkflowAdminPaneController {
.retractTask(theTask, assignment.getRole()));
if (roleIds != null) {
final List<Role> roles = Arrays
.stream(roleIds)
.map(roleId -> Long.parseLong(roleId))
.map(roleId -> roleRepo.findById(roleId).orElseThrow(
() -> new IllegalArgumentException(String.format(
"No role with ID %d in the database. "
+ "Where did that ID come from?", roleId))))
.collect(Collectors.toList());
final List<Role> roles = Arrays
.stream(roleIds)
.map(roleId -> Long.parseLong(roleId))
.map(roleId -> roleRepo.findById(roleId).orElseThrow(
() -> new IllegalArgumentException(String.format(
"No role with ID %d in the database. "
+ "Where did that ID come from?", roleId))))
.collect(Collectors.toList());
roles.forEach(role -> assignableTaskManager
.assignTask(theTask, role));
}
}
}
@Transactional(Transactional.TxType.REQUIRED)
public void removeAssignment(final Task task, final String roleId ) {
public void removeAssignment(final Task task, final String roleId) {
final Role role = roleRepo
.findById(Long.parseLong(roleId))
.orElseThrow(() -> new IllegalArgumentException(String.format(
.findById(Long.parseLong(roleId))
.orElseThrow(() -> new IllegalArgumentException(String.format(
"No Role with ID %s in the database. Where did that ID come from?",
roleId)));
final CmsTask theTask = (CmsTask) taskRepo
final CmsTask theTask = (CmsTask) taskRepo
.findById(task.getTaskId())
.orElseThrow(() -> new IllegalArgumentException(String.format(
"No Task with ID %d in the database. Where did that ID come from?",
task.getTaskId())));
assignableTaskManager.retractTask(theTask, role);
assignableTaskManager.retractTask(theTask, role);
}
}

View File

@ -26,8 +26,7 @@ import com.arsdigita.cms.CMS;
import com.arsdigita.kernel.KernelConfig;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contentsection.ContentSection;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import java.util.Iterator;
import java.util.Locale;
@ -49,8 +48,8 @@ class WorkflowListModelBuilder extends AbstractListModelBuilder {
private class Model implements ListModel {
private final Iterator<WorkflowTemplate> templates;
private WorkflowTemplate currentTemplate;
private final Iterator<Workflow> templates;
private Workflow currentTemplate;
public Model() {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();

View File

@ -29,8 +29,8 @@ import com.arsdigita.kernel.KernelConfig;
import java.util.List;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentSection;
import org.libreccm.workflow.WorkflowTemplate;
/**
* Builds a list of workflow templates registered to the current content
@ -41,7 +41,7 @@ import org.libreccm.workflow.WorkflowTemplate;
*/
public class WorkflowsOptionPrintListener implements PrintListener {
protected List<WorkflowTemplate> getCollection(final PageState state) {
protected List<Workflow> getCollection(final PageState state) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowsOptionPrintListenerController controller = cdiUtil
@ -62,9 +62,9 @@ public class WorkflowsOptionPrintListener implements PrintListener {
final OptionGroup target = (OptionGroup) event.getTarget();
target.clearOptions();
final List<WorkflowTemplate> templates = getCollection(state);
final List<Workflow> templates = getCollection(state);
for (final WorkflowTemplate template : templates) {
for (final Workflow template : templates) {
target.addOption(new Option(
Long.toString(template.getWorkflowId()),
template.getName().getValue(KernelConfig

View File

@ -19,7 +19,7 @@
package com.arsdigita.cms.ui.workflow;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentSectionRepository;
@ -41,7 +41,7 @@ class WorkflowsOptionPrintListenerController {
private ContentSectionRepository sectionRepo;
@Transactional(Transactional.TxType.REQUIRED)
protected List<WorkflowTemplate> getWorkflowTemplates(
protected List<Workflow> getWorkflowTemplates(
final ContentSection section) {
Objects.requireNonNull(section);

View File

@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Collections;
import org.libreccm.categorization.Category;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.lifecycle.LifecycleDefinition;
import java.util.List;
@ -38,7 +37,6 @@ import javax.inject.Inject;
import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.AuthorizationRequired;
@ -212,7 +210,7 @@ public class ContentItemManager {
* {@link ContentSection#rootDocumentsFolder} of the provided content
* section. Otherwise an {@link IllegalArgumentException} is thrown.
*
* Likewise the provided {@link WorkflowTemplate} must be defined in the
* Likewise the provided abstract {@link Workflow} must be defined in the
* provided content section. Otherwise an {@link IllegalArgumentException}
* is thrown.
*
@ -235,7 +233,7 @@ public class ContentItemManager {
final ContentSection section,
@RequiresPrivilege(ItemPrivileges.CREATE_NEW)
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Workflow workflowTemplate,
final Class<T> type,
final Locale locale) {
@ -258,7 +256,7 @@ public class ContentItemManager {
* {@link ContentSection#rootDocumentsFolder} of the provided content
* section. Otherwise an {@link IllegalArgumentException} is thrown.
*
* Likewise the provided {@link WorkflowTemplate} must be defined in the
* Likewise the provided abstract {@link Workflow} must be defined in the
* provided content section. Otherwise an {@link IllegalArgumentException}
* is thrown.
*
@ -283,7 +281,7 @@ public class ContentItemManager {
final ContentSection section,
@RequiresPrivilege(ItemPrivileges.CREATE_NEW)
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Workflow workflowTemplate,
final Class<T> type,
final ContentItemInitializer<T> initializer,
final Locale locale) {
@ -490,13 +488,10 @@ public class ContentItemManager {
throw new RuntimeException(ex);
}
// final String uuid = UUID.randomUUID().toString();
// copy.setUuid(uuid);
// copy.setItemUuid(uuid);
copy.setContentType(contentType.get());
if (draftItem.getWorkflow() != null) {
final WorkflowTemplate template = draftItem.getWorkflow()
final Workflow template = draftItem.getWorkflow()
.getTemplate();
final Workflow copyWorkflow = workflowManager.createWorkflow(
template, item);

View File

@ -21,6 +21,7 @@ package org.librecms.contentsection;
import org.libreccm.security.RecursivePermissions;
import org.libreccm.security.Role;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.Workflow;
import java.io.Serializable;
import java.util.Collections;
@ -42,7 +43,6 @@ import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.contentsection.privileges.AssetPrivileges;
import org.librecms.contentsection.privileges.ItemPrivileges;
import org.librecms.contentsection.privileges.TypePrivileges;
@ -58,53 +58,53 @@ import static org.librecms.CmsConstants.*;
@Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA)
@NamedQueries({
@NamedQuery(
name = "ContentSection.findById",
query = "SELECT S FROM ContentSection s WHERE s.objectId = :objectId")
name = "ContentSection.findById",
query = "SELECT S FROM ContentSection s WHERE s.objectId = :objectId")
,
@NamedQuery(
name = "ContentSection.findByLabel",
query = "SELECT s FROM ContentSection s WHERE s.label = :label")
name = "ContentSection.findByLabel",
query = "SELECT s FROM ContentSection s WHERE s.label = :label")
,
@NamedQuery(
name = "ContentSection.findUsableContentTypes",
query = "SELECT t FROM ContentType t "
+ "WHERE t.contentSection = :section "
+ "AND "
+ "(t IN (SELECT p.object FROM Permission p "
+ "WHERE p.grantedPrivilege = '"
+ TypePrivileges.USE_TYPE + "' "
+ "AND p.grantee in :roles) "
+ "OR true = :isSysAdmin)")
name = "ContentSection.findUsableContentTypes",
query = "SELECT t FROM ContentType t "
+ "WHERE t.contentSection = :section "
+ "AND "
+ "(t IN (SELECT p.object FROM Permission p "
+ "WHERE p.grantedPrivilege = '"
+ TypePrivileges.USE_TYPE + "' "
+ "AND p.grantee in :roles) "
+ "OR true = :isSysAdmin)")
,
@NamedQuery(
name = "ContentSection.countUsableContentTypes",
query = "SELECT COUNT(t) FROM ContentType t "
+ "WHERE t.contentSection = :section "
+ "AND "
+ "(t IN (SELECT p.object FROM Permission p "
+ "WHERE p.grantedPrivilege = '"
+ TypePrivileges.USE_TYPE + "' "
+ "AND p.grantee IN :roles) "
+ "OR true = :isSysAdmin)")
name = "ContentSection.countUsableContentTypes",
query = "SELECT COUNT(t) FROM ContentType t "
+ "WHERE t.contentSection = :section "
+ "AND "
+ "(t IN (SELECT p.object FROM Permission p "
+ "WHERE p.grantedPrivilege = '"
+ TypePrivileges.USE_TYPE + "' "
+ "AND p.grantee IN :roles) "
+ "OR true = :isSysAdmin)")
,
@NamedQuery(
name = "ContentSection.hasUsableContentTypes",
query = "SELECT (CASE WHEN COUNT(t) > 0 THEN true ELSE false END)"
+ "FROM ContentType t "
+ "WHERE t.contentSection = :section "
+ "AND "
+ "(t IN (SELECT p.object FROM Permission p "
+ "WHERE p.grantedPrivilege = '"
+ TypePrivileges.USE_TYPE + "' "
+ "AND p.grantee IN :roles) "
+ "OR true = :isSysAdmin)")
name = "ContentSection.hasUsableContentTypes",
query = "SELECT (CASE WHEN COUNT(t) > 0 THEN true ELSE false END)"
+ "FROM ContentType t "
+ "WHERE t.contentSection = :section "
+ "AND "
+ "(t IN (SELECT p.object FROM Permission p "
+ "WHERE p.grantedPrivilege = '"
+ TypePrivileges.USE_TYPE + "' "
+ "AND p.grantee IN :roles) "
+ "OR true = :isSysAdmin)")
,
@NamedQuery(
name = "ContentSection.findPermissions",
query = "SELECT p FROM Permission p "
+ "WHERE (p.object = :section "
+ " OR p.object = :rootDocumentsFolder"
+ " OR p.object = :rootAssetsFolder) "
name = "ContentSection.findPermissions",
query = "SELECT p FROM Permission p "
+ "WHERE (p.object = :section "
+ " OR p.object = :rootDocumentsFolder"
+ " OR p.object = :rootAssetsFolder) "
+ "AND p.grantee = :role")
})
//@ApplicationType(
@ -184,29 +184,29 @@ public class ContentSection extends CcmApplication implements Serializable {
@OneToMany
@JoinTable(
name = "CONTENT_SECTION_LIFECYCLE_DEFINITIONS",
schema = DB_SCHEMA,
joinColumns = {
@JoinColumn(name = "CONTENT_SECTION_ID")
},
inverseJoinColumns = {
@JoinColumn(name = "LIFECYCLE_DEFINITION_ID")
}
name = "CONTENT_SECTION_LIFECYCLE_DEFINITIONS",
schema = DB_SCHEMA,
joinColumns = {
@JoinColumn(name = "CONTENT_SECTION_ID")
},
inverseJoinColumns = {
@JoinColumn(name = "LIFECYCLE_DEFINITION_ID")
}
)
private List<LifecycleDefinition> lifecycleDefinitions = new ArrayList<>();
@OneToMany
@JoinTable(
name = "CONTENT_SECTION_WORKFLOW_TEMPLATES",
schema = DB_SCHEMA,
joinColumns = {
@JoinColumn(name = "CONTENT_SECTION_ID")
},
inverseJoinColumns = {
@JoinColumn(name = "WORKFLOW_TEMPLATE_ID")
}
name = "CONTENT_SECTION_WORKFLOW_TEMPLATES",
schema = DB_SCHEMA,
joinColumns = {
@JoinColumn(name = "CONTENT_SECTION_ID")
},
inverseJoinColumns = {
@JoinColumn(name = "WORKFLOW_TEMPLATE_ID")
}
)
private List<WorkflowTemplate> workflowTemplates = new ArrayList<>();
private List<Workflow> workflowTemplates = new ArrayList<>();
public ContentSection() {
roles = new ArrayList<>();
@ -326,7 +326,7 @@ public class ContentSection extends CcmApplication implements Serializable {
}
protected void setLifecycleDefinitions(
final List<LifecycleDefinition> lifecycleDefinitions) {
final List<LifecycleDefinition> lifecycleDefinitions) {
this.lifecycleDefinitions = lifecycleDefinitions;
}
@ -335,24 +335,28 @@ public class ContentSection extends CcmApplication implements Serializable {
}
protected void removeLifecycleDefinition(
final LifecycleDefinition definition) {
final LifecycleDefinition definition) {
lifecycleDefinitions.remove(definition);
}
public List<WorkflowTemplate> getWorkflowTemplates() {
public List<Workflow> getWorkflowTemplates() {
return Collections.unmodifiableList(workflowTemplates);
}
protected void setWorkflowTemplates(
final List<WorkflowTemplate> workflowTemplates) {
final List<Workflow> workflowTemplates) {
this.workflowTemplates = workflowTemplates;
}
protected void addWorkflowTemplate(final WorkflowTemplate template) {
protected void addWorkflowTemplate(final Workflow template) {
if (!template.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not an abstract workflow.");
}
workflowTemplates.add(template);
}
protected void removeWorkflowTemplate(final WorkflowTemplate template) {
protected void removeWorkflowTemplate(final Workflow template) {
workflowTemplates.remove(template);
}
@ -422,23 +426,23 @@ public class ContentSection extends CcmApplication implements Serializable {
@Override
public String toString(final String data) {
return super.toString(String.format(
", label = \"%s\", "
+ "rootDocumentsFolder = \"%s\", "
+ "rootAssetsFolder = \"%s\", "
+ "pageResolverClass = \"%s\", "
+ "itemResolverClass = \"%s\", "
+ "templateResolverClass = \"%s\", "
+ "xmlGeneratorClass = \"%s\", "
+ "defaultLocale = \"%s\"%s",
label,
Objects.toString(rootDocumentsFolder),
Objects.toString(rootAssetsFolder),
pageResolverClass,
itemResolverClass,
templateResolverClass,
xmlGeneratorClass,
Objects.toString(defaultLocale),
data));
", label = \"%s\", "
+ "rootDocumentsFolder = \"%s\", "
+ "rootAssetsFolder = \"%s\", "
+ "pageResolverClass = \"%s\", "
+ "itemResolverClass = \"%s\", "
+ "templateResolverClass = \"%s\", "
+ "xmlGeneratorClass = \"%s\", "
+ "defaultLocale = \"%s\"%s",
label,
Objects.toString(rootDocumentsFolder),
Objects.toString(rootAssetsFolder),
pageResolverClass,
itemResolverClass,
templateResolverClass,
xmlGeneratorClass,
Objects.toString(defaultLocale),
data));
}
}

View File

@ -30,7 +30,7 @@ import org.libreccm.security.PermissionManager;
import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import java.util.List;
import java.util.Locale;
@ -54,6 +54,8 @@ import java.util.Optional;
import org.librecms.contentsection.privileges.TypePrivileges;
import org.librecms.dispatcher.ItemResolver;
import java.util.Objects;
import javax.enterprise.inject.Instance;
import static org.librecms.contentsection.ContentSection.*;
@ -86,7 +88,7 @@ public class ContentSectionManager {
@Inject
private ConfigurationManager confManager;
@Inject
private Instance<ItemResolver> itemResolvers;
@ -104,11 +106,11 @@ public class ContentSectionManager {
public ContentSection createContentSection(final String name) {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(
"The name of a ContentSection can't be blank.");
"The name of a ContentSection can't be blank.");
}
final KernelConfig kernelConfig = confManager.findConfiguration(
KernelConfig.class);
KernelConfig.class);
final Locale defautLocale = kernelConfig.getDefaultLocale();
final ContentSection section = new ContentSection();
@ -257,21 +259,21 @@ public class ContentSectionManager {
* {@link CmsConstants#AdminPrivileges.ADMINISTER_ROLES} for the provided
* content section.
*
* @param section The {@link ContentSection} to which the role is added.
* @param roleName The name of the new role.
* @param section The {@link ContentSection} to which the role is added.
* @param roleName The name of the new role.
* @param privileges The privileges of the new role.
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void addRoleToContentSection(
@RequiresPrivilege(AdminPrivileges.ADMINISTER_ROLES)
final ContentSection section,
final String roleName,
final String... privileges) {
@RequiresPrivilege(AdminPrivileges.ADMINISTER_ROLES)
final ContentSection section,
final String roleName,
final String... privileges) {
if (section == null) {
throw new IllegalArgumentException("Can't add a role to "
+ "section null.");
+ "section null.");
}
if (roleName == null || roleName.trim().isEmpty()) {
@ -296,24 +298,24 @@ public class ContentSectionManager {
* requires {@link CmsConstants#AdminPrivileges.ADMINISTER_ROLES} for the
* provided content section.
*
* @param role The role to add.
* @param role The role to add.
* @param section The section the role is associated with.
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void addRoleToContentSection(
final Role role,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_ROLES)
final ContentSection section) {
final Role role,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_ROLES)
final ContentSection section) {
if (section == null) {
throw new IllegalArgumentException("Can't add a role to "
+ "section null.");
+ "section null.");
}
if (role == null) {
throw new IllegalArgumentException("Can't add role null to a "
+ "content section.");
+ "content section.");
}
section.addRole(role);
@ -329,18 +331,18 @@ public class ContentSectionManager {
* content section.
*
* @param contentSection The section from which the role is removed.
* @param role The role to remove from the content section.
* @param role The role to remove from the content section.
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void removeRoleFromContentSection(
@RequiresPrivilege(AdminPrivileges.ADMINISTER_ROLES)
final ContentSection contentSection,
final Role role) {
@RequiresPrivilege(AdminPrivileges.ADMINISTER_ROLES)
final ContentSection contentSection,
final Role role) {
if (contentSection == null) {
throw new IllegalArgumentException(
"Can't remove role from ContentSection null");
"Can't remove role from ContentSection null");
}
if (role == null) {
@ -349,10 +351,10 @@ public class ContentSectionManager {
contentSection.removeRole(role);
sectionRepo.save(contentSection);
final TypedQuery<Permission> query = entityManager
.createNamedQuery("ContentSection.findPermissions",
Permission.class);
.createNamedQuery("ContentSection.findPermissions",
Permission.class);
query.setParameter("section", contentSection);
query.setParameter("rootDocumentsFolder",
contentSection.getRootDocumentsFolder());
@ -370,14 +372,14 @@ public class ContentSectionManager {
* provided content section.
*
* @param definition The lifecycle definition to add.
* @param section The section to which the definition is added.
* @param section The section to which the definition is added.
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void addLifecycleDefinitionToContentSection(
final LifecycleDefinition definition,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_LIFECYLES)
final ContentSection section) {
final LifecycleDefinition definition,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_LIFECYLES)
final ContentSection section) {
section.addLifecycleDefinition(definition);
sectionRepo.save(section);
@ -389,14 +391,14 @@ public class ContentSectionManager {
* the provided content section.
*
* @param definition The definition to remove.
* @param section The section from which the definition is removed.
* @param section The section from which the definition is removed.
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void removeLifecycleDefinitionFromContentSection(
final LifecycleDefinition definition,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_LIFECYLES)
final ContentSection section) {
final LifecycleDefinition definition,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_LIFECYLES)
final ContentSection section) {
section.removeLifecycleDefinition(definition);
sectionRepo.save(section);
@ -408,14 +410,22 @@ public class ContentSectionManager {
* content section.
*
* @param template The template to add.
* @param section The content section to which the template is added.
* @param section The content section to which the template is added.
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void addWorkflowTemplateToContentSection(
final WorkflowTemplate template,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_WORKFLOW)
final ContentSection section) {
final Workflow template,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_WORKFLOW)
final ContentSection section) {
Objects.requireNonNull(template);
Objects.requireNonNull(section);
if (!template.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not abstract workflow.");
}
section.addWorkflowTemplate(template);
sectionRepo.save(section);
@ -427,14 +437,14 @@ public class ContentSectionManager {
* provided content section.
*
* @param template The template to remove.
* @param section The section from which the template is removed.
* @param section The section from which the template is removed.
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void removeWorkflowTemplateFromContentSection(
final WorkflowTemplate template,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_WORKFLOW)
final ContentSection section) {
final Workflow template,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_WORKFLOW)
final ContentSection section) {
section.removeWorkflowTemplate(template);
sectionRepo.save(section);
@ -444,7 +454,7 @@ public class ContentSectionManager {
* Retrieves the {@link ItemResolver} for the provided content section.
*
* @param section The section for which the {@link ItemResolver} is
* retrieved.
* retrieved.
*
* @return The {@link ItemResolver} for the provided content section.
*/
@ -452,15 +462,15 @@ public class ContentSectionManager {
try {
@SuppressWarnings("unchecked")
final Class<ItemResolver> itemResolverClazz
= (Class<ItemResolver>) Class.
forName(section.getItemResolverClass());
= (Class<ItemResolver>) Class.
forName(section.getItemResolverClass());
final Instance<ItemResolver> instance = itemResolvers.select(
itemResolverClazz);
if (instance.isUnsatisfied()) {
throw new UnexpectedErrorException(String.format(
"No ItemResolver \"{}\" found.",
"No ItemResolver \"{}\" found.",
itemResolverClazz.getName()));
} else {
return instance.get();
@ -476,72 +486,80 @@ public class ContentSectionManager {
* {@link CmsConstants#AdminPrivileges.ADMINISTER_CONTENT_TYPES} for the
* provided content section.
*
* @param type The type to add (a subclass of {@link ContentItem}.
* @param section The section to which the type is added.
* @param type The type to add (a subclass of
* {@link ContentItem}.
* @param section The section to which the type is added.
* @param defaultLifecycle The default lifecycle for items of the provided
* type in the provided content section. The lifecycle must be part of the
* provided section. Otherwise an {@link IllegalArgumentException} is
* thrown.
* @param defaultWorkflow The default workflow for items of the provided
* type in the provided content section. The workflow must be part of the
* provided section. Otherwise an {@link IllegalArgumentException} is
* thrown.
* type in the provided content section. The
* lifecycle must be part of the provided section.
* Otherwise an {@link IllegalArgumentException} is
* thrown.
* @param defaultWorkflow The default workflow for items of the provided
* type in the provided content section. The
* workflow must be part of the provided section.
* Otherwise an {@link IllegalArgumentException} is
* thrown.
*
* @return The new {@link ContentType} instance.
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public ContentType addContentTypeToSection(
final Class<? extends ContentItem> type,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_CONTENT_TYPES)
final ContentSection section,
final LifecycleDefinition defaultLifecycle,
final WorkflowTemplate defaultWorkflow) {
final Class<? extends ContentItem> type,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_CONTENT_TYPES)
final ContentSection section,
final LifecycleDefinition defaultLifecycle,
final Workflow defaultWorkflow) {
if (type == null) {
throw new IllegalArgumentException("Can't add null as content type "
+ "to a content section.");
+ "to a content section.");
}
if (section == null) {
throw new IllegalArgumentException("Can't add a content type"
+ "to section null.");
+ "to section null.");
}
if (defaultLifecycle == null) {
throw new IllegalArgumentException("Can't create a content type "
+ "without a default lifecycle.");
+ "without a default lifecycle.");
}
if (defaultWorkflow == null) {
throw new IllegalArgumentException("Can't create a content type "
+ "without a default workflow.");
+ "without a default workflow.");
}
if (!defaultWorkflow.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not an abstract workflow.");
}
if (!section.getLifecycleDefinitions().contains(defaultLifecycle)) {
final KernelConfig kernelConfig = confManager.findConfiguration(
KernelConfig.class);
KernelConfig.class);
final Locale defaultLocale = kernelConfig.getDefaultLocale();
throw new IllegalArgumentException(String.format(
"The provided default lifecycle %d\"%s\" is not part of the"
+ "provided content section %d\"%s\".",
defaultLifecycle.getDefinitionId(),
defaultLifecycle.getLabel().getValue(defaultLocale),
section.getObjectId(),
section.getDisplayName()));
"The provided default lifecycle %d\"%s\" is not part of the"
+ "provided content section %d\"%s\".",
defaultLifecycle.getDefinitionId(),
defaultLifecycle.getLabel().getValue(defaultLocale),
section.getObjectId(),
section.getDisplayName()));
}
if (!section.getWorkflowTemplates().contains(defaultWorkflow)) {
final KernelConfig kernelConfig = confManager.findConfiguration(
KernelConfig.class);
KernelConfig.class);
final Locale defaultLocale = kernelConfig.getDefaultLocale();
throw new IllegalArgumentException(String.format(
"The provided default workflow %d\"%s\" is not part of the"
+ "provided content section %d\"%s\".",
defaultWorkflow.getWorkflowId(),
defaultWorkflow.getName().getValue(defaultLocale),
section.getObjectId(),
section.getDisplayName()));
"The provided default workflow %d\"%s\" is not part of the"
+ "provided content section %d\"%s\".",
defaultWorkflow.getWorkflowId(),
defaultWorkflow.getName().getValue(defaultLocale),
section.getObjectId(),
section.getDisplayName()));
}
if (hasContentType(type, section)) {
@ -560,10 +578,10 @@ public class ContentSectionManager {
sectionRepo.save(section);
typeRepo.save(contentType);
section.getRoles().stream()
.forEach(role -> permissionManager.grantPrivilege(
TypePrivileges.USE_TYPE, role, contentType));
.forEach(role -> permissionManager.grantPrivilege(
TypePrivileges.USE_TYPE, role, contentType));
return contentType;
}
@ -572,11 +590,11 @@ public class ContentSectionManager {
* Checks if a content section has a {@link ContentType} for a specific
* subclass {@link ContentItem}.
*
* @param type The type to check for.
* @param type The type to check for.
* @param section The section to check for the {@link ContentType}.
*
* @return {@code true} if the section has a {@link ContentType} for
* {@code type}, {@code false} if not.
* {@code type}, {@code false} if not.
*/
public boolean hasContentType(final Class<? extends ContentItem> type,
final ContentSection section) {
@ -590,7 +608,7 @@ public class ContentSectionManager {
}
final Optional<ContentType> result = typeRepo
.findByContentSectionAndClass(section, type);
.findByContentSectionAndClass(section, type);
return result.isPresent();
}
@ -601,20 +619,21 @@ public class ContentSectionManager {
* {@link CmsConstants#AdminPrivileges.ADMINISTER_CONTENT_TYPES} for the
* provided content section.
*
* @param type The type to remove from the section.
* @param type The type to remove from the section.
* @param section The section from which the type is removed.
*
* @throws IllegalArgumentException if the provided {@link ContentType} is
* in use or the parameters or otherwise illegal.
* in use or the parameters or otherwise
* illegal.
* @see
* ContentTypeRepository#delete(org.librecms.contentsection.ContentType)
*/
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public void removeContentTypeFromSection(
final Class<? extends ContentItem> type,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_CONTENT_TYPES)
final ContentSection section) {
final Class<? extends ContentItem> type,
@RequiresPrivilege(AdminPrivileges.ADMINISTER_CONTENT_TYPES)
final ContentSection section) {
if (type == null) {
throw new IllegalArgumentException("Can't remove content type null.");
@ -622,11 +641,11 @@ public class ContentSectionManager {
if (section == null) {
throw new IllegalArgumentException("Can't remove a content type "
+ "from section null.");
+ "from section null.");
}
final Optional<ContentType> contentType = typeRepo
.findByContentSectionAndClass(section, type);
.findByContentSectionAndClass(section, type);
if (!contentType.isPresent()) {
return;
@ -634,12 +653,12 @@ public class ContentSectionManager {
if (typeRepo.isContentTypeInUse(contentType.get())) {
throw new IllegalArgumentException(String.format(
"ContentType %d:\"%s\" is used by content section %d:\"%s\" and "
+ "can't be deleted.",
contentType.get().getObjectId(),
contentType.get().getDisplayName(),
section.getObjectId(),
section.getDisplayName()));
"ContentType %d:\"%s\" is used by content section %d:\"%s\" and "
+ "can't be deleted.",
contentType.get().getObjectId(),
contentType.get().getDisplayName(),
section.getObjectId(),
section.getDisplayName()));
}
typeRepo.delete(contentType.get());

View File

@ -25,7 +25,7 @@ import static org.librecms.CmsConstants.*;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.lifecycle.LifecycleDefinition;
import java.io.Serializable;
@ -117,14 +117,14 @@ public class ContentType extends CcmObject implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DEFAULT_WORKFLOW")
private WorkflowTemplate defaultWorkflow;
private Workflow defaultWorkflow;
public ContentType() {
super();
label = new LocalizedString();
description = new LocalizedString();
}
public String getContentItemClass() {
return contentItemClass;
}
@ -192,11 +192,15 @@ public class ContentType extends CcmObject implements Serializable {
this.defaultLifecycle = defaultLifecycle;
}
public WorkflowTemplate getDefaultWorkflow() {
public Workflow getDefaultWorkflow() {
return defaultWorkflow;
}
protected void setDefaultWorkflow(final WorkflowTemplate defaultWorkflow) {
protected void setDefaultWorkflow(final Workflow defaultWorkflow) {
if (!defaultWorkflow.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not an abstract workflow.");
}
this.defaultWorkflow = defaultWorkflow;
}

View File

@ -24,10 +24,12 @@ import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.PermissionManager;
import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Role;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.privileges.AdminPrivileges;
import org.librecms.lifecycle.LifecycleDefinition;
import java.util.Objects;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
@ -98,7 +100,7 @@ public class ContentTypeManager {
* Sets the default workflow to use for new items of a content type.
*
* @param type
* @param template The {@link WorkflowTemplate} for the workflow to use for
* @param template The abstract {@link Workflow} for the workflow to use for
* new items of the provided {@code type}.
*/
@Transactional(Transactional.TxType.REQUIRED)
@ -106,7 +108,15 @@ public class ContentTypeManager {
public void setDefaultWorkflow(
@RequiresPrivilege(AdminPrivileges.ADMINISTER_CONTENT_TYPES)
final ContentType type,
final WorkflowTemplate template) {
final Workflow template) {
Objects.requireNonNull(type);
Objects.requireNonNull(template);
if (!template.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"The provided workflow is not an abstract workflow.");
}
type.setDefaultWorkflow(template);

View File

@ -22,7 +22,7 @@ import org.libreccm.categorization.Category;
import org.libreccm.categorization.Domain;
import org.libreccm.security.Role;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.lifecycle.LifecycleDefinition;
@ -66,7 +66,7 @@ public final class AdminPrivileges {
*/
public static final String ADMINISTER_ROLES = "administer_roles";
/**
* Allows manipulation of the {@link WorkflowTemplate}s assigned to a
* Allows manipulation of the (abstract) {@link Workflow}s assigned to a
* {@link ContentSection}.
*
* @see ContentSection#workflowTemplates

View File

@ -0,0 +1,17 @@
drop constraint FKrx08cdjm9tutrp5lvfhgslw48;
alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES
add constraint FK1t85m4jehnhd6tyx5dtpavr15
foreign key (WORKFLOW_TEMPLATE_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CMS.CONTENT_TYPES
drop constraint if exists FKhnu9oikw8rpf22lt5fmk41t7k;
alter table CCM_CMS.CONTENT_TYPES
add constraint FKpgeccqsr50xwb268ypmfx0r66
foreign key (DEFAULT_WORKFLOW)
references CCM_CORE.WORKFLOWS;
alter table if exists FKeixdxau4jebw682gd49tdbsjy
drop constraint FKeixdxau4jebw682gd49tdbsjy;

View File

@ -0,0 +1,17 @@
drop constraint FKrx08cdjm9tutrp5lvfhgslw48;
alter table CCM_CMS.CONTENT_SECTION_WORKFLOW_TEMPLATES
add constraint FK1t85m4jehnhd6tyx5dtpavr15
foreign key (WORKFLOW_TEMPLATE_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CMS.CONTENT_TYPES
drop constraint if exists FKhnu9oikw8rpf22lt5fmk41t7k;
alter table CCM_CMS.CONTENT_TYPES
add constraint FKpgeccqsr50xwb268ypmfx0r66
foreign key (DEFAULT_WORKFLOW)
references CCM_CORE.WORKFLOWS;
alter table if exists FKeixdxau4jebw682gd49tdbsjy
drop constraint FKeixdxau4jebw682gd49tdbsjy;

View File

@ -23,6 +23,7 @@ import java.util.Optional;
import static org.libreccm.testutils.DependenciesHelpers.*;
import org.apache.shiro.subject.ExecutionException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.arquillian.junit.Arquillian;
@ -51,10 +52,13 @@ import java.util.Locale;
import javax.activation.MimeType;
import javax.activation.MimeTypeParseException;
import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.librecms.assets.FileAsset;
import java.util.concurrent.Callable;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@ -212,19 +216,24 @@ public class AssetManagerTest {
"timestamp",
"uuid"})
public void shareAsset() throws MimeTypeParseException {
final Folder folder = folderRepo.findById(-420L).get();
assertThat(folder, is(not(nullValue())));
final FileAsset file = new FileAsset();
file.setDisplayName("datasheet.pdf");
file.setFileName("datasheet.pdf");
file.setMimeType(new MimeType("application/pdf"));
file.getTitle().addValue(Locale.ENGLISH, "datasheet.pdf");
assetRepo.save(file);
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-420L).get();
assertThat(folder, is(not(nullValue())));
assetManager.shareAsset(file, folder);
final FileAsset file = new FileAsset();
file.setDisplayName("datasheet.pdf");
file.setFileName("datasheet.pdf");
file.setMimeType(new MimeType("application/pdf"));
file.getTitle().addValue(Locale.ENGLISH, "datasheet.pdf");
assetRepo.save(file);
assetManager.shareAsset(file, folder);
assertThat(file.getDisplayName(), is(equalTo("datasheet.pdf")));
return null;
});
assertThat(file.getDisplayName(), is(equalTo("datasheet.pdf")));
}
/**
@ -241,9 +250,12 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void shareAssetNull() {
final Folder folder = folderRepo.findById(-420L).get();
assetManager.shareAsset(null, folder);
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-420L).get();
assetManager.shareAsset(null, folder);
});
}
/**
@ -261,13 +273,22 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void shareAssetFolderIsNull() throws MimeTypeParseException {
final FileAsset file = new FileAsset();
file.setDisplayName("datasheet.pdf");
file.setFileName("datasheet.pdf");
file.setMimeType(new MimeType("application/pdf"));
public void shareAssetFolderIsNull() throws Throwable {
assetManager.shareAsset(file, null);
try {
shiro.getSystemUser().execute(() -> {
final FileAsset file = new FileAsset();
file.setDisplayName("datasheet.pdf");
file.setFileName("datasheet.pdf");
file.setMimeType(new MimeType("application/pdf"));
assetManager.shareAsset(file, null);
return null;
});
} catch (ExecutionException ex) {
//We need the original exception
throw ex.getCause();
}
}
/**
@ -284,11 +305,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void shareAlreadySharedAsset() {
final Folder folder = folderRepo.findById(-420L).get();
final Asset asset = assetRepo.findById(-700L).get();
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-420L).get();
assetManager.shareAsset(asset, folder);
final Asset asset = assetRepo.findById(-700L).get();
assetManager.shareAsset(asset, folder);
});
}
/**
@ -304,7 +328,9 @@ public class AssetManagerTest {
+ "after-clean-orphaned.xml",
excludeColumns = {"timestamp", "object_order"})
public void cleanOrphanedAssets() {
assetManager.cleanOrphanedAssets();
shiro.getSystemUser().execute(() -> {
assetManager.cleanOrphanedAssets();
});
}
/**
@ -324,11 +350,17 @@ public class AssetManagerTest {
"object_order",
"uuid"})
public void moveAssetToOtherFolder() {
final Asset asset = assetRepo.findById(-900L).get();
final Folder folder = folderRepo.findById(-410L).get();
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-900L).get();
assetManager.move(asset, folder);
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-410L).get();
assetManager.move(asset, folder);
});
return null;
});
}
/**
@ -348,11 +380,14 @@ public class AssetManagerTest {
"object_order",
"uuid"})
public void moveAssetToFolderInOtherContentSection() {
final Asset asset = assetRepo.findById(-900L).get();
final Folder folder = folderRepo.findById(-1600L).get();
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-900L).get();
assetManager.move(asset, folder);
final Folder folder = folderRepo.findById(-1600L).get();
assetManager.move(asset, folder);
});
}
/**
@ -371,9 +406,11 @@ public class AssetManagerTest {
public void moveAssetNull() {
final Asset asset = null;
final Folder folder = folderRepo.findById(-410L).get();
shiro.getSystemUser().execute(() -> {
final Folder folder = folderRepo.findById(-410L).get();
assetManager.move(asset, folder);
assetManager.move(asset, folder);
});
}
/**
@ -390,11 +427,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void moveAssetTargetFolderIsNull() {
final Asset asset = assetRepo.findById(-900L).get();
final Folder targetFolder = null;
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-900L).get();
assetManager.move(asset, targetFolder);
final Folder targetFolder = null;
assetManager.move(asset, targetFolder);
});
}
/**
@ -411,11 +451,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void moveAssetTargetFolderIsNotAssetFolder() {
final Asset asset = assetRepo.findById(-900L).get();
final Folder folder = folderRepo.findById(-200L).get();
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-900L).get();
assetManager.move(asset, folder);
final Folder folder = folderRepo.findById(-200L).get();
assetManager.move(asset, folder);
});
}
/**
@ -438,11 +481,14 @@ public class AssetManagerTest {
"categorization_id",
"object_order"})
public void copyAssetToOtherFolder() {
final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = folderRepo.findById(-400L).get();
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get();
assetManager.copy(asset, targetFolder);
final Folder targetFolder = folderRepo.findById(-400L).get();
assetManager.copy(asset, targetFolder);
});
}
/**
@ -496,11 +542,14 @@ public class AssetManagerTest {
"categorization_id",
"object_order"})
public void copyAssetToOtherContentSection() {
final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = folderRepo.findById(-1600L).get();
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get();
assetManager.copy(asset, targetFolder);
final Folder targetFolder = folderRepo.findById(-1600L).get();
assetManager.copy(asset, targetFolder);
});
}
/**
@ -517,11 +566,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void copyAssetNull() {
final Asset asset = null;
final Folder targetFolder = folderRepo.findById(-420L).get();
shiro.getSystemUser().execute(() -> {
final Asset asset = null;
assetManager.copy(asset, targetFolder);
final Folder targetFolder = folderRepo.findById(-420L).get();
assetManager.copy(asset, targetFolder);
});
}
/**
@ -538,11 +590,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void copyAssetTargetFolderIsNull() {
final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = null;
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get();
assetManager.copy(asset, targetFolder);
final Folder targetFolder = null;
assetManager.copy(asset, targetFolder);
});
}
/**
@ -559,11 +614,14 @@ public class AssetManagerTest {
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
@ShouldThrowException(IllegalArgumentException.class)
public void copyAssetTargetFolderIsNotAssetFolder() {
final Asset asset = assetRepo.findById(-1100L).get();
final Folder targetFolder = folderRepo.findById(-200L).get();
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-1100L).get();
assetManager.copy(asset, targetFolder);
final Folder targetFolder = folderRepo.findById(-200L).get();
assetManager.copy(asset, targetFolder);
});
}
/**
@ -578,17 +636,22 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyIsAssetInUse() {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(assetManager.isAssetInUse(header), is(true));
assertThat(assetManager.isAssetInUse(phb), is(false));
assertThat(assetManager.isAssetInUse(servicesHeader), is(true));
assertThat(assetManager.isAssetInUse(product1Datasheet), is(true));
assertThat(assetManager.isAssetInUse(catalog), is(true));
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(assetManager.isAssetInUse(header), is(true));
assertThat(assetManager.isAssetInUse(phb), is(false));
assertThat(assetManager.isAssetInUse(servicesHeader), is(true));
assertThat(assetManager.isAssetInUse(product1Datasheet), is(true));
assertThat(assetManager.isAssetInUse(catalog), is(true));
return null;
});
}
/**
@ -603,22 +666,25 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetPathWithoutContentSection() {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(assetManager.getAssetPath(header),
is(equalTo("/media/images/header.png")));
assertThat(assetManager.getAssetPath(phb),
is(equalTo("/media/images/the-phb.png")));
assertThat(assetManager.getAssetPath(servicesHeader),
is(equalTo("/media/services-header.png")));
assertThat(assetManager.getAssetPath(product1Datasheet),
is(equalTo("")));
assertThat(assetManager.getAssetPath(catalog),
is(equalTo("/media/downloads/catalog.pdf")));
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(assetManager.getAssetPath(header),
is(equalTo("/media/images/header.png")));
assertThat(assetManager.getAssetPath(phb),
is(equalTo("/media/images/the-phb.png")));
assertThat(assetManager.getAssetPath(servicesHeader),
is(equalTo("/media/services-header.png")));
assertThat(assetManager.getAssetPath(product1Datasheet),
is(equalTo("")));
assertThat(assetManager.getAssetPath(catalog),
is(equalTo("/media/downloads/catalog.pdf")));
});
}
/**
@ -633,22 +699,25 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetPathWithContentSection() {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(assetManager.getAssetPath(header, true),
is(equalTo("info:/media/images/header.png")));
assertThat(assetManager.getAssetPath(phb, true),
is(equalTo("info:/media/images/the-phb.png")));
assertThat(assetManager.getAssetPath(servicesHeader, true),
is(equalTo("info:/media/services-header.png")));
assertThat(assetManager.getAssetPath(product1Datasheet, true),
is(equalTo("")));
assertThat(assetManager.getAssetPath(catalog, true),
is(equalTo("info:/media/downloads/catalog.pdf")));
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
assertThat(assetManager.getAssetPath(header, true),
is(equalTo("info:/media/images/header.png")));
assertThat(assetManager.getAssetPath(phb, true),
is(equalTo("info:/media/images/the-phb.png")));
assertThat(assetManager.getAssetPath(servicesHeader, true),
is(equalTo("info:/media/services-header.png")));
assertThat(assetManager.getAssetPath(product1Datasheet, true),
is(equalTo("")));
assertThat(assetManager.getAssetPath(catalog, true),
is(equalTo("info:/media/downloads/catalog.pdf")));
});
}
/**
@ -663,37 +732,40 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetFolder() {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
final Folder media = folderRepo.findById(-400L).get();
final Folder images = folderRepo.findById(-410L).get();
final Folder downloads = folderRepo.findById(-420L).get();
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
final Optional<Folder> headerFolder = assetManager
.getAssetFolder(header);
final Optional<Folder> phbFolder = assetManager
.getAssetFolder(phb);
final Optional<Folder> servicesHeaderFolder = assetManager
.getAssetFolder(servicesHeader);
final Optional<Folder> product1DatasheetFolder = assetManager
.getAssetFolder(product1Datasheet);
final Optional<Folder> catalogFolder = assetManager
.getAssetFolder(catalog);
final Folder media = folderRepo.findById(-400L).get();
final Folder images = folderRepo.findById(-410L).get();
final Folder downloads = folderRepo.findById(-420L).get();
assertThat(headerFolder.isPresent(), is(true));
assertThat(phbFolder.isPresent(), is(true));
assertThat(servicesHeaderFolder.isPresent(), is(true));
assertThat(product1DatasheetFolder.isPresent(), is(false));
assertThat(catalogFolder.isPresent(), is(true));
final Optional<Folder> headerFolder = assetManager
.getAssetFolder(header);
final Optional<Folder> phbFolder = assetManager
.getAssetFolder(phb);
final Optional<Folder> servicesHeaderFolder = assetManager
.getAssetFolder(servicesHeader);
final Optional<Folder> product1DatasheetFolder = assetManager
.getAssetFolder(product1Datasheet);
final Optional<Folder> catalogFolder = assetManager
.getAssetFolder(catalog);
assertThat(headerFolder.get(), is(equalTo(images)));
assertThat(phbFolder.get(), is(equalTo(images)));
assertThat(servicesHeaderFolder.get(), is(equalTo(media)));
assertThat(catalogFolder.get(), is(equalTo(downloads)));
assertThat(headerFolder.isPresent(), is(true));
assertThat(phbFolder.isPresent(), is(true));
assertThat(servicesHeaderFolder.isPresent(), is(true));
assertThat(product1DatasheetFolder.isPresent(), is(false));
assertThat(catalogFolder.isPresent(), is(true));
assertThat(headerFolder.get(), is(equalTo(images)));
assertThat(phbFolder.get(), is(equalTo(images)));
assertThat(servicesHeaderFolder.get(), is(equalTo(media)));
assertThat(catalogFolder.get(), is(equalTo(downloads)));
});
}
/**
@ -708,58 +780,63 @@ public class AssetManagerTest {
@ShouldMatchDataSet(
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
public void verifyGetAssetFolders() {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
final Folder infoAssets = folderRepo.findById(-300L).get();
final Folder media = folderRepo.findById(-400L).get();
final Folder images = folderRepo.findById(-410L).get();
final Folder downloads = folderRepo.findById(-420L).get();
shiro.getSystemUser().execute(() -> {
final Asset header = assetRepo.findById(-700L).get();
final Asset phb = assetRepo.findById(-800L).get();
final Asset servicesHeader = assetRepo.findById(-900L).get();
final Asset product1Datasheet = assetRepo.findById(-1000L).get();
final Asset catalog = assetRepo.findById(-1100L).get();
final List<Folder> headerFolders = assetManager.getAssetFolders(header);
final List<Folder> phbFolders = assetManager.getAssetFolders(phb);
final List<Folder> servicesHeaderFolders = assetManager.getAssetFolders(
servicesHeader);
final List<Folder> product1DatasheetFolders = assetManager.
getAssetFolders(product1Datasheet);
final List<Folder> catalogFolders = assetManager.
getAssetFolders(catalog);
final Folder infoAssets = folderRepo.findById(-300L).get();
final Folder media = folderRepo.findById(-400L).get();
final Folder images = folderRepo.findById(-410L).get();
final Folder downloads = folderRepo.findById(-420L).get();
assertThat(headerFolders, is(not(nullValue())));
assertThat(phbFolders, is(not(nullValue())));
assertThat(servicesHeaderFolders, is(not(nullValue())));
assertThat(product1DatasheetFolders, is(not(nullValue())));
assertThat(catalogFolders, is(not(nullValue())));
final List<Folder> headerFolders = assetManager.getAssetFolders(
header);
final List<Folder> phbFolders = assetManager.getAssetFolders(phb);
final List<Folder> servicesHeaderFolders = assetManager
.getAssetFolders(
servicesHeader);
final List<Folder> product1DatasheetFolders = assetManager.
getAssetFolders(product1Datasheet);
final List<Folder> catalogFolders = assetManager.
getAssetFolders(catalog);
assertThat(headerFolders.isEmpty(), is(false));
assertThat(phbFolders.isEmpty(), is(false));
assertThat(servicesHeaderFolders.isEmpty(), is(false));
assertThat(product1DatasheetFolders.isEmpty(), is(true));
assertThat(catalogFolders.isEmpty(), is(false));
assertThat(headerFolders, is(not(nullValue())));
assertThat(phbFolders, is(not(nullValue())));
assertThat(servicesHeaderFolders, is(not(nullValue())));
assertThat(product1DatasheetFolders, is(not(nullValue())));
assertThat(catalogFolders, is(not(nullValue())));
assertThat(headerFolders.size(), is(3));
assertThat(phbFolders.size(), is(3));
assertThat(servicesHeaderFolders.size(), is(2));
assertThat(product1DatasheetFolders.size(), is(0));
assertThat(catalogFolders.size(), is(3));
assertThat(headerFolders.isEmpty(), is(false));
assertThat(phbFolders.isEmpty(), is(false));
assertThat(servicesHeaderFolders.isEmpty(), is(false));
assertThat(product1DatasheetFolders.isEmpty(), is(true));
assertThat(catalogFolders.isEmpty(), is(false));
assertThat(headerFolders.get(0), is(equalTo(infoAssets)));
assertThat(headerFolders.get(1), is(equalTo(media)));
assertThat(headerFolders.get(2), is(equalTo(images)));
assertThat(headerFolders.size(), is(3));
assertThat(phbFolders.size(), is(3));
assertThat(servicesHeaderFolders.size(), is(2));
assertThat(product1DatasheetFolders.size(), is(0));
assertThat(catalogFolders.size(), is(3));
assertThat(phbFolders.get(0), is(equalTo(infoAssets)));
assertThat(phbFolders.get(1), is(equalTo(media)));
assertThat(phbFolders.get(2), is(equalTo(images)));
assertThat(headerFolders.get(0), is(equalTo(infoAssets)));
assertThat(headerFolders.get(1), is(equalTo(media)));
assertThat(headerFolders.get(2), is(equalTo(images)));
assertThat(servicesHeaderFolders.get(0), is(equalTo(infoAssets)));
assertThat(servicesHeaderFolders.get(1), is(equalTo(media)));
assertThat(phbFolders.get(0), is(equalTo(infoAssets)));
assertThat(phbFolders.get(1), is(equalTo(media)));
assertThat(phbFolders.get(2), is(equalTo(images)));
assertThat(catalogFolders.get(0), is(equalTo(infoAssets)));
assertThat(catalogFolders.get(1), is(equalTo(media)));
assertThat(catalogFolders.get(2), is(equalTo(downloads)));
assertThat(servicesHeaderFolders.get(0), is(equalTo(infoAssets)));
assertThat(servicesHeaderFolders.get(1), is(equalTo(media)));
assertThat(catalogFolders.get(0), is(equalTo(infoAssets)));
assertThat(catalogFolders.get(1), is(equalTo(media)));
assertThat(catalogFolders.get(2), is(equalTo(downloads)));
});
}

View File

@ -20,6 +20,7 @@ package org.librecms.contentsection;
import static org.libreccm.testutils.DependenciesHelpers.*;
import org.apache.shiro.subject.ExecutionException;
import org.apache.shiro.subject.Subject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
@ -56,6 +57,8 @@ import org.librecms.assets.Image;
import org.librecms.assets.VideoAsset;
import org.librecms.contentsection.rs.Assets;
import java.util.concurrent.Callable;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@ -202,15 +205,19 @@ public class AssetRepositoryTest {
excludeColumns = {"timestamp", "object_order"}
)
public void deleteUnusedAsset() {
final Asset asset = assetRepo.findById(-800L).get();
assetRepo.delete(asset);
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-800L).get();
assetRepo.delete(asset);
});
}
/**
* Verifies that an {@link Asset} which is associated to at least one
* {@link ContentItem} can't be deleted by using
* {@link AssetRepository#delete(org.librecms.assets.Asset)}.
* @throws java.lang.Throwable
*/
@Test(expected = AssetInUseException.class)
@InSequence(110)
@ -220,10 +227,18 @@ public class AssetRepositoryTest {
"datasets/org/librecms/contentsection/AssetRepositoryTest/"
+ "data.xml")
@ShouldThrowException(AssetInUseException.class)
public void deleteUsedAsset() {
final Asset asset = assetRepo.findById(-700L).get();
public void deleteUsedAsset() throws Throwable {
assetRepo.delete(asset);
try {
shiro.getSystemUser().execute(() -> {
final Asset asset = assetRepo.findById(-700L).get();
assetRepo.delete(asset);
return null;
});
} catch (ExecutionException ex) {
throw ex.getCause();
}
}
/**
@ -234,6 +249,7 @@ public class AssetRepositoryTest {
@InSequence(200)
@UsingDataSet(
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
public void findAssetByUuid() {
final Optional<Asset> header = shiro
@ -341,7 +357,6 @@ public class AssetRepositoryTest {
assertThat(images.get(1).getDisplayName(),
is(equalTo("services-header.png")));
assertThat(images.get(2).getDisplayName(), is(equalTo("the-phb.png")));
assertThat(files.get(0).getDisplayName(), is(equalTo("catalog.pdf")));
assertThat(files.get(1).getDisplayName(),
@ -487,7 +502,7 @@ public class AssetRepositoryTest {
assertThat(files.get(0).getDisplayName(), is(equalTo("catalog.pdf")));
assertThat(files.get(1).getDisplayName(),
is(equalTo("product1-datasheet.pdf")));
}
/**

View File

@ -39,8 +39,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.libreccm.security.Shiro;
import org.libreccm.tests.categories.IntegrationTest;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.librecms.contenttypes.Article;
import org.librecms.contenttypes.Event;
import org.librecms.lifecycle.LifecycleDefinition;
@ -52,6 +50,7 @@ import java.util.Optional;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.jboss.arquillian.persistence.TestExecutionPhase;
@ -60,6 +59,9 @@ import static org.junit.Assert.*;
import static org.libreccm.testutils.DependenciesHelpers.*;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
/**
* Tests for the {@link ContentItemManager}.
*
@ -90,7 +92,7 @@ public class ContentItemManagerTest {
private Shiro shiro;
@Inject
private WorkflowTemplateRepository workflowTemplateRepo;
private WorkflowRepository workflowRepo;
@Inject
private LifecycleDefinitionRepository lifecycleDefinitionRepo;
@ -194,7 +196,7 @@ public class ContentItemManagerTest {
assertThat(itemManager, is(not(nullValue())));
assertThat(folderRepo, is(not(nullValue())));
assertThat(shiro, is(not(nullValue())));
assertThat(workflowTemplateRepo, is(not(nullValue())));
assertThat(workflowRepo, is(not(nullValue())));
assertThat(lifecycleDefinitionRepo, is(not(nullValue())));
assertThat(entityManager, is(not(nullValue())));
}
@ -418,8 +420,9 @@ public class ContentItemManagerTest {
.get();
final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L).get();
final Workflow workflowTemplate = workflowRepo
.findById(-110L)
.get();
final Article article = itemManager.createContentItem(
"new-article",
@ -466,8 +469,9 @@ public class ContentItemManagerTest {
.get();
final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L).get();
final Workflow workflowTemplate = workflowRepo
.findById(-110L)
.get();
itemManager.createContentItem("Test",
section,
@ -499,8 +503,9 @@ public class ContentItemManagerTest {
.get();
final Folder folder = section.getRootDocumentsFolder();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L).get();
final Workflow workflowTemplate = workflowRepo
.findById(-110L)
.get();
itemManager.createContentItem(null,
section,
@ -561,8 +566,9 @@ public class ContentItemManagerTest {
.findByLabel("info")
.get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-110L).get();
final Workflow workflowTemplate = workflowRepo
.findById(-110L)
.get();
itemManager.createContentItem("Test",
section,

View File

@ -152,11 +152,11 @@ public class ContentItemPermissionTest {
.addClass(org.libreccm.workflow.TaskComment.class)
.addClass(org.libreccm.workflow.TaskState.class)
.addClass(org.libreccm.workflow.Workflow.class)
.addClass(org.libreccm.workflow.AbstractWorkflowException.class)
//Classes required by org.libreccm.categorization.Category
.addClass(org.libreccm.security.RecursivePermissions.class)
//Classes required by org.libreccm.workflow.Workflow.class
.addClass(org.libreccm.workflow.WorkflowState.class)
.addClass(org.libreccm.workflow.WorkflowTemplate.class)
//Classes required by org.librecms.contentsection.ContentItem
.addClass(org.librecms.contentsection.AttachmentList.class)
.addClass(org.librecms.contentsection.ContentItemVersion.class)

View File

@ -57,8 +57,8 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.jboss.arquillian.persistence.TestExecutionPhase;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateRepository;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowRepository;
import org.librecms.contentsection.privileges.ItemPrivileges;
import org.librecms.contenttypes.Article;
import org.librecms.contenttypes.Event;
@ -102,7 +102,7 @@ public class ContentSectionManagerTest {
private LifecycleDefinitionRepository lifecycleDefRepo;
@Inject
private WorkflowTemplateRepository workflowTemplateRepo;
private WorkflowRepository workflowRepo;
public ContentSectionManagerTest() {
}
@ -198,7 +198,7 @@ public class ContentSectionManagerTest {
assertThat(categoryRepo, is(not(nullValue())));
assertThat(typeRepo, is(not(nullValue())));
assertThat(lifecycleDefRepo, is(not(nullValue())));
assertThat(workflowTemplateRepo, is(not(nullValue())));
assertThat(workflowRepo, is(not(nullValue())));
}
/**
@ -449,9 +449,11 @@ public class ContentSectionManagerTest {
public void addContentTypeToSection() {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14001L).get();
.findById(-13002L)
.get();
final Workflow workflowTemplate = workflowRepo
.findById(-14001L)
.get();
manager.addContentTypeToSection(Event.class,
section,
@ -474,9 +476,11 @@ public class ContentSectionManagerTest {
public void addAlreadyAddedContentTypeToSection() {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
.findById(-14002L).get();
.findById(-13002L)
.get();
final Workflow workflowTemplate = workflowRepo
.findById(-14002L)
.get();
manager.addContentTypeToSection(News.class,
section,
@ -501,7 +505,7 @@ public class ContentSectionManagerTest {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14002L).get();
manager.addContentTypeToSection(null,
@ -527,7 +531,7 @@ public class ContentSectionManagerTest {
public void addContentTypeToSectionSectionIsNull() {
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14002L).get();
manager.addContentTypeToSection(Event.class,
@ -551,7 +555,7 @@ public class ContentSectionManagerTest {
@InSequence(800)
public void addContentTypeToSectionLifecycleIsNull() {
final ContentSection section = repository.findById(-1100L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14001L).get();
manager.addContentTypeToSection(Event.class,
@ -602,7 +606,7 @@ public class ContentSectionManagerTest {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13003L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14001L).get();
manager.addContentTypeToSection(Event.class,
@ -628,7 +632,7 @@ public class ContentSectionManagerTest {
final ContentSection section = repository.findById(-1100L).get();
final LifecycleDefinition lifecycleDef = lifecycleDefRepo
.findById(-13002L).get();
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
final Workflow workflowTemplate = workflowRepo
.findById(-14003L).get();
manager.addContentTypeToSection(Event.class,

View File

@ -388,7 +388,7 @@ public class ContentTypeRepositoryTest {
.addClass(org.libreccm.workflow.TaskState.class)
.addClass(org.libreccm.workflow.Workflow.class)
.addClass(org.libreccm.workflow.WorkflowState.class)
.addClass(org.libreccm.workflow.WorkflowTemplate.class)
.addClass(org.libreccm.workflow.AbstractWorkflowException.class)
.addClass(org.librecms.CmsConstants.class)
.addClass(org.librecms.contentsection.Asset.class)
.addClass(org.librecms.contentsection.AttachmentList.class)

View File

@ -30,12 +30,11 @@ import org.libreccm.security.User;
import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.Workflow;
import org.librecms.lifecycle.LifecycleDefinition;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
/**
*
@ -143,14 +142,12 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
final LifecycleDefinition lifecycleDef2 = new LifecycleDefinition();
lifecycleDef2.setDefinitionId(-110);
final WorkflowTemplate workflowTemplate1 = new WorkflowTemplate();
workflowTemplate1.getName().addValue(Locale.ENGLISH,
"Workflow Template 1");
final WorkflowTemplate workflowTemplate2 = new WorkflowTemplate();
workflowTemplate2.getName().addValue(Locale.ENGLISH,
"Workflow Template 2");
final Workflow workflow1 = new Workflow();
workflow1.setAbstractWorkflow(true);
final Workflow workflow2 = new Workflow();
workflow2.setAbstractWorkflow(false);
verifier
.withPrefabValues(ContentItem.class, item1, item2)
@ -167,9 +164,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
.withPrefabValues(LifecycleDefinition.class,
lifecycleDef1,
lifecycleDef2)
.withPrefabValues(WorkflowTemplate.class,
workflowTemplate1,
workflowTemplate2);
.withPrefabValues(Workflow.class, workflow1, workflow2);
}
/**

View File

@ -82,8 +82,6 @@ DELETE FROM ccm_core.workflow_task_descriptions;
DELETE FROM ccm_cms.content_section_workflow_templates;
DELETE FROM ccm_core.workflow_templates;
DELETE FROM ccm_core.workflows;
DELETE FROM ccm_cms.lifecycle_phase_definition_labels;

View File

@ -82,8 +82,6 @@ DELETE FROM ccm_core.workflow_task_descriptions;
DELETE FROM ccm_cms.content_section_workflow_templates;
DELETE FROM ccm_core.workflow_templates;
DELETE FROM ccm_core.workflows;
DELETE FROM ccm_cms.lifecycle_phase_definition_labels;

View File

@ -0,0 +1,67 @@
/*
* Copyright (C) 2017 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class AbstractWorkflowException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* Creates a new instance of <code>AbstractWorkflowException</code> without detail message.
*/
public AbstractWorkflowException() {
super();
}
/**
* Constructs an instance of <code>AbstractWorkflowException</code> with the specified detail message.
*
* @param msg The detail message.
*/
public AbstractWorkflowException(final String msg) {
super(msg);
}
/**
* Constructs an instance of <code>AbstractWorkflowException</code> which wraps the
* specified exception.
*
* @param exception The exception to wrap.
*/
public AbstractWorkflowException(final Exception exception) {
super(exception);
}
/**
* Constructs an instance of <code>AbstractWorkflowException</code> with the specified message which also wraps the
* specified exception.
*
* @param msg The detail message.
* @param exception The exception to wrap.
*/
public AbstractWorkflowException(final String msg, final Exception exception) {
super(msg, exception);
}
}

View File

@ -29,6 +29,7 @@ import org.libreccm.portation.Portable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
@ -37,6 +38,8 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import java.util.Locale;
/**
* A workflow is a collection of tasks which are performed on an object. Tasks
* can depend on each other.
@ -78,13 +81,18 @@ public class Workflow implements Identifiable, Serializable, Portable {
@NotNull
private String uuid;
/**
* Indicates that this {@code Workflow} can be assigned to an object.
*/
@Column(name = "abstract_workflow")
private boolean abstractWorkflow;
/**
* The template which was used to generate the workflow.
*/
@ManyToOne
@JoinColumn(name = "TEMPLATE_ID")
@JsonIdentityReference(alwaysAsId = true)
private WorkflowTemplate template;
private Workflow template;
/**
* Human readable name of the workflow.
@ -173,11 +181,19 @@ public class Workflow implements Identifiable, Serializable, Portable {
this.uuid = uuid;
}
public WorkflowTemplate getTemplate() {
public boolean isAbstractWorkflow() {
return abstractWorkflow;
}
public void setAbstractWorkflow(boolean abstractWorkflow) {
this.abstractWorkflow = abstractWorkflow;
}
public Workflow getTemplate() {
return template;
}
protected void setTemplate(final WorkflowTemplate template) {
protected void setTemplate(final Workflow template) {
this.template = template;
}
@ -228,6 +244,11 @@ public class Workflow implements Identifiable, Serializable, Portable {
}
protected void setObject(final CcmObject object) {
if (abstractWorkflow) {
throw new AbstractWorkflowException(String.format(
"Workflow %s is abstrct and can not assigned to an object.",
uuid));
}
this.object = object;
}
@ -257,6 +278,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
hash = 79 * hash + (int) (workflowId ^ (workflowId >>> 32));
hash = 79 * hash + Objects.hashCode(uuid);
hash = 79 * hash + Objects.hashCode(name);
hash = 79 * hash + (abstractWorkflow ? 1 : 0);
hash = 79 * hash + Objects.hashCode(description);
hash = 79 * hash + Objects.hashCode(state);
hash = 79 * hash + (active ? 1 : 0);
@ -289,6 +311,10 @@ public class Workflow implements Identifiable, Serializable, Portable {
return false;
}
if (abstractWorkflow != other.isAbstractWorkflow()) {
return false;
}
if (!Objects.equals(description, other.getDescription())) {
return false;
}
@ -319,6 +345,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
+ "uuid = \"%s\", "
+ "name = \"%s\", "
+ "description = \"%s\", "
+ "abstractWorkflow = %b, "
+ "state = \"%s\", "
+ "active = %b%s"
+ " }",
@ -327,6 +354,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
uuid,
Objects.toString(name),
Objects.toString(description),
abstractWorkflow,
Objects.toString(state),
active,
data);

View File

@ -19,6 +19,7 @@
package org.libreccm.workflow;
import com.arsdigita.kernel.KernelConfig;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.subject.Subject;
@ -37,13 +38,22 @@ import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
/**
* Manager for {@link Workflow}s. The logic of some of these classes has been
@ -109,18 +119,18 @@ public class WorkflowManager {
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
public Workflow createWorkflow(final WorkflowTemplate template,
public Workflow createWorkflow(final Workflow template,
final CcmObject object) {
if (template == null) {
Objects.requireNonNull(template,
"Can't create a workflow without a template.");
if (!template.isAbstractWorkflow()) {
throw new IllegalArgumentException(
"Can't create a workflow without a template.");
}
if (object == null) {
throw new IllegalArgumentException(
"Can't create a workflow without an object.");
"The provided template is not an abstract workflow");
}
Objects.requireNonNull(object,
"Can't create a workflow without an object.");
final Workflow workflow = new Workflow();
final LocalizedString name = new LocalizedString();
@ -219,8 +229,8 @@ public class WorkflowManager {
writeMethod.invoke(task, value);
}
} catch (IllegalAccessException
| IllegalArgumentException
| InvocationTargetException ex) {
| IllegalArgumentException
| InvocationTargetException ex) {
throw new RuntimeException();
}
}

View File

@ -1,98 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.core.CcmObject;
import org.libreccm.portation.Portable;
import org.libreccm.security.GroupIdResolver;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import java.io.Serializable;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/**
* Objects of these class are used as templates for new workflows. The tasks
* in the template are copied when a new workflow is generated.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "WORKFLOW_TEMPLATES", schema = DB_SCHEMA)
@NamedQueries({
@NamedQuery(
name = "WorkflowTemplate.findByUuid",
query = "SELECT t FROM WorkflowTemplate t " +
"WHERE t.uuid = :uuid")
})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = WorkflowTemplateIdResolver.class,
property = "uuid")
public class WorkflowTemplate extends Workflow implements Serializable,
Portable {
private static final long serialVersionUID = 5770519379144947171L;
/**
* A workflow template has no object. Therefore the {@code setObject
* (CcmObject)} method has been overwritten to throw an
* {@link UnsupportedOperationException} when called on the workflow
* template.
*
* @param object
*/
@Override
protected void setObject(final CcmObject object) {
//throw new UnsupportedOperationException(
// "A WorkflowTemplate has no object.");
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof WorkflowTemplate)) {
return false;
}
final WorkflowTemplate other = (WorkflowTemplate) obj;
return other.canEqual(obj);
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof WorkflowTemplate;
}
}

View File

@ -1,62 +0,0 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
import org.libreccm.cdi.utils.CdiUtil;
import javax.enterprise.context.RequestScoped;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 9/6/17
*/
@RequestScoped
public class WorkflowTemplateIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowTemplateRepository workflowTemplateRepository = cdiUtil
.findBean(WorkflowTemplateRepository.class);
return workflowTemplateRepository
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No workflow templates with uuid %s in the " +
"database.", id.key.toString())));
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new WorkflowTemplateIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof WorkflowTemplateIdResolver;
}
}

View File

@ -1,50 +0,0 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import org.libreccm.portation.AbstractMarshaller;
import org.libreccm.portation.Marshals;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 11/21/16
*/
@RequestScoped
@Marshals(WorkflowTemplate.class)
public class WorkflowTemplateMarshaller extends
AbstractMarshaller<WorkflowTemplate> {
@Inject
private WorkflowTemplateRepository workflowTemplateRepository;
@Override
protected Class<WorkflowTemplate> getObjectClass() {
return WorkflowTemplate.class;
}
@Override
@Transactional(Transactional.TxType.REQUIRED)
protected void insertIntoDb(WorkflowTemplate portableObject) {
workflowTemplateRepository.save(portableObject);
}
}

View File

@ -1,80 +0,0 @@
/*
* Copyright (C) 2016 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import org.libreccm.core.AbstractEntityRepository;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import java.util.Optional;
import java.util.UUID;
/**
* A repository for {@link WorkflowTemplate}s.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class WorkflowTemplateRepository
extends AbstractEntityRepository<Long, WorkflowTemplate> {
@Override
public Class<WorkflowTemplate> getEntityClass() {
return WorkflowTemplate.class;
}
@Override
public boolean isNew(final WorkflowTemplate template) {
return template.getWorkflowId() == 0;
}
@Override
public void initNewEntity(final WorkflowTemplate workflowTemplate) {
super.initNewEntity(workflowTemplate);
workflowTemplate.setUuid(UUID.randomUUID().toString());
}
/**
* Find a {@link WorkflowTemplate} by its UUID.
*
* @param uuid The UUID of the {@link WorkflowTemplate} to find.
*
* @return An {@link Optional} containing the {@link WorkflowTemplate}
* identified by the provided UUID.
*/
public Optional<WorkflowTemplate> findByUuid(final String uuid) {
if (uuid == null || uuid.trim().isEmpty()) {
throw new IllegalArgumentException(
"The UUID of the WorkflowTemplate to retrieve can't be " +
"null or empty.");
}
final TypedQuery<WorkflowTemplate> query = getEntityManager()
.createNamedQuery("WorkflowTemplate.findByUuid",
WorkflowTemplate.class);
query.setParameter("uuid", uuid);
try {
return Optional.of(query.getSingleResult());
} catch(NoResultException ex) {
return Optional.empty();
}
}
}

View File

@ -0,0 +1,13 @@
alter table CCM_CORE.WORKFLOWS add column ABSTRACT_WORKFLOW boolean;
update CCM_CORE.WORKFLOWS set ABSTRACT_WORKFLOW = true
where WORKFLOW_ID in (select WORKFLOW_ID from CCM_CORE.WORKFLOW_TEMPLATES);
alter table CCM_CORE.WORKFLOW_TEMPLATES
drop constraint if exists FK8692vdme4yxnkj1m0k1dw74pk;
alter table CCM_CORE.WORKFLOWS
drop constraint if exists FKeixdxau4jebw682gd49tdbsjy;
drop table CCM_CORE.WORKFLOW_TEMPLATES cascade;

View File

@ -0,0 +1,13 @@
alter table CCM_CORE.WORKFLOWS add column ABSTRACT_WORKFLOW boolean;
update CCM_CORE.WORKFLOWS set ABSTRACT_WORKFLOW = true
where WORKFLOW_ID in (select WORKFLOW_ID from CCM_CORE.WORKFLOW_TEMPLATES);
alter table CCM_CORE.WORKFLOW_TEMPLATES
drop constraint if exists FK8692vdme4yxnkj1m0k1dw74pk;
alter table CCM_CORE.WORKFLOWS
drop constraint if exists FKeixdxau4jebw682gd49tdbsjy;
drop table CCM_CORE.WORKFLOW_TEMPLATES cascade;

View File

@ -144,7 +144,7 @@ public class CoreDataImportTest {
Assert.assertFalse(importHelper.importPermissions());
Assert.assertFalse(importHelper.importWorkflowTemplates());
// Assert.assertFalse(importHelper.importWorkflowTemplates());
Assert.assertFalse(importHelper.importWorkflows());
Assert.assertFalse(importHelper.importTaskComments());
//Assert.assertFalse(importHelper.importAssignableTasks());

View File

@ -79,13 +79,6 @@ class ImportHelper {
@Marshals(DomainOwnership.class)
private DomainOwnershipMarshaller domainOwnershipMarshaller;
@Inject
@Marshals(Permission.class)
private PermissionMarshaller permissionMarshaller;
@Inject
@Marshals(WorkflowTemplate.class)
private WorkflowTemplateMarshaller workflowTemplateMarshaller;
@Inject
@Marshals(Workflow.class)
private WorkflowMarshaller workflowMarshaller;
@ -209,14 +202,6 @@ class ImportHelper {
return permissionMarshaller.importFile();
}
boolean importWorkflowTemplates() {
workflowTemplateMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"workflowTemplates.xml",
indentation);
return workflowTemplateMarshaller.importFile();
}
boolean importWorkflows() {
workflowMarshaller.prepare(

View File

@ -109,36 +109,36 @@ public class PermissionManagerTest {
@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap
.create(WebArchive.class,
"LibreCCM-org.libreccm.security.PermissionManagerTest.war").
addPackage(org.libreccm.categorization.Categorization.class
.getPackage())
.addPackage(org.libreccm.configuration.Configuration.class
.getPackage())
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
.getPackage())
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
.getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
addPackage(org.libreccm.security.User.class.getPackage())
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
.getPackage())
.addPackage(org.libreccm.testutils.EqualsVerifier.class
.getPackage())
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()).
addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage())
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
.addClass(org.libreccm.portation.Portable.class)
.addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml",
"META-INF/persistence.xml")
.addAsResource("configs/shiro.ini", "shiro.ini")
.addAsWebInfResource("test-web.xml", "web.xml")
.addAsWebInfResource("META-INF/beans.xml", "beans.xml");
.create(WebArchive.class,
"LibreCCM-org.libreccm.security.PermissionManagerTest.war").
addPackage(org.libreccm.categorization.Categorization.class
.getPackage())
.addPackage(org.libreccm.configuration.Configuration.class
.getPackage())
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
.getPackage())
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
.getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
addPackage(org.libreccm.security.User.class.getPackage())
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
.getPackage())
.addPackage(org.libreccm.testutils.EqualsVerifier.class
.getPackage())
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()).
addPackage(com.arsdigita.kernel.security.SecurityConfig.class
.getPackage())
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
.addClass(org.libreccm.portation.Portable.class)
.addAsLibraries(getModuleDependencies())
.addAsResource("test-persistence.xml",
"META-INF/persistence.xml")
.addAsResource("configs/shiro.ini", "shiro.ini")
.addAsWebInfResource("test-web.xml", "web.xml")
.addAsWebInfResource("META-INF/beans.xml", "beans.xml");
}
/**
@ -177,11 +177,11 @@ public class PermissionManagerTest {
*/
@Test
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-grant.yml",
excludeColumns = {"permission_id"})
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-grant.yml",
excludeColumns = {"permission_id"})
@InSequence(200)
public void grantPermission() {
final Role role2 = roleRepository.findByName("role2").get();
@ -202,10 +202,10 @@ public class PermissionManagerTest {
*/
@Test
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "data.yml")
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "data.yml")
@InSequence(210)
public void grantPermissionAgain() {
final Role role1 = roleRepository.findByName("role1").get();
@ -224,11 +224,11 @@ public class PermissionManagerTest {
*/
@Test
@UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/"
+ "data-recursivly.yml")
+ "data-recursivly.yml")
@ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-grant-recursivly.yml",
excludeColumns = {"permission_id"})
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-grant-recursivly.yml",
excludeColumns = {"permission_id"})
@InSequence(211)
public void grantPermissionRecursively() {
final Role role1 = roleRepository.findByName("role1").get();
@ -249,7 +249,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(220)
public void grantPermissionPrivilegeNull() throws Throwable {
@ -257,7 +257,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.grantPrivilege(null, role1));
() -> permissionManager.grantPrivilege(null, role1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -273,7 +273,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(225)
public void grantPermissionOnObjectPrivilegeNull() throws Throwable {
@ -282,7 +282,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.grantPrivilege(null, role1, object1));
() -> permissionManager.grantPrivilege(null, role1, object1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -298,7 +298,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(230)
public void grantPermissionEmptyPrivilege() throws Throwable {
@ -306,7 +306,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.grantPrivilege("", role1));
() -> permissionManager.grantPrivilege("", role1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -322,7 +322,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(235)
public void grantPermissionOnObjectEmptyPrivilege() throws Throwable {
@ -331,7 +331,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.grantPrivilege("", role1, object1));
() -> permissionManager.grantPrivilege("", role1, object1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -347,13 +347,13 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(240)
public void grantPermissionToRoleNull() throws Throwable {
try {
shiro.getSystemUser().execute(
() -> permissionManager.grantPrivilege("privilege", null));
() -> permissionManager.grantPrivilege("privilege", null));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -369,7 +369,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(240)
public void grantPermissionOnObjectToRoleNull() throws Throwable {
@ -377,9 +377,9 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.grantPrivilege("privilege",
null,
object1));
() -> permissionManager.grantPrivilege("privilege",
null,
object1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -395,7 +395,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(250)
public void grantPermissionNullObject() throws Throwable {
@ -403,9 +403,9 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.grantPrivilege("privilege1",
role1,
null));
() -> permissionManager.grantPrivilege("privilege1",
role1,
null));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -420,11 +420,11 @@ public class PermissionManagerTest {
*/
@Test
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-revoke.yml",
excludeColumns = {"permission_id"})
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-revoke.yml",
excludeColumns = {"permission_id"})
@InSequence(300)
public void revokePermission() {
final Role role1 = roleRepository.findByName("role1").get();
@ -446,16 +446,16 @@ public class PermissionManagerTest {
*/
@Test
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "data.yml")
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "data.yml")
@InSequence(310)
public void revokeNotExistingPermission() throws Throwable {
final Role role1 = roleRepository.findByName("role1").get();
shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege("privilege999", role1));
() -> permissionManager.revokePrivilege("privilege999", role1));
}
/**
@ -464,10 +464,10 @@ public class PermissionManagerTest {
*/
@Test
@UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-grant-recursivly.yml")
+ "after-grant-recursivly.yml")
@ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-revoke-recursivly.yml")
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-revoke-recursivly.yml")
@InSequence(311)
public void revokePermissionRecursivly() {
final Role role1 = roleRepository.findByName("role1").get();
@ -487,19 +487,19 @@ public class PermissionManagerTest {
*/
@Test
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "data.yml")
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "data.yml")
@InSequence(310)
public void revokeNotExistingPermissionOnObject() {
final Role role1 = roleRepository.findByName("role1").get();
final CcmObject object1 = ccmObjectRepository.findById(-20001L).get();
shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege("privilege999",
role1,
object1));
() -> permissionManager.revokePrivilege("privilege999",
role1,
object1));
}
/**
@ -512,7 +512,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(320)
public void revokePermissionPrivilegeNull() throws Throwable {
@ -520,7 +520,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege(null, role1));
() -> permissionManager.revokePrivilege(null, role1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -536,7 +536,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(320)
public void revokePermissionOnObjectPrivilegeNull() throws Throwable {
@ -545,8 +545,8 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.
revokePrivilege(null, role1, object1));
() -> permissionManager.
revokePrivilege(null, role1, object1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -562,7 +562,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(330)
public void revokePermissionEmptyPrivilege() throws Throwable {
@ -570,7 +570,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege("", role1));
() -> permissionManager.revokePrivilege("", role1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -579,15 +579,14 @@ public class PermissionManagerTest {
/**
* Verifies that
* {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role, org.libreccm.core.CcmObject)}
* throws an {@link IllegalArgumentException} if called with {@code null}
* for the privilege to revoke.
* throws an {@link NullPointerException} if called with {@code null} for
* the privilege to revoke.
*
* @throws Throwable
*/
@Test(expected
= IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(320)
public void revokePermissionOnObjectEmptyPrivilege() throws Throwable {
@ -596,7 +595,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege("", role1, object1));
() -> permissionManager.revokePrivilege("", role1, object1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -605,21 +604,20 @@ public class PermissionManagerTest {
/**
* Verifies that
* {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role)}
* throws an {@link IllegalArgumentException} if called with {@code null}
* for the role to revoke the permission from.
* throws an {@link NullPointerException} if called with {@code null} for
* the role to revoke the permission from.
*
* @throws Throwable
*/
@Test(expected
= IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@Test(expected = IllegalArgumentException.class)
@UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/"
+ "data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(340)
public void revokePermissionFromRoleNull() throws Throwable {
try {
shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege("privilege1", null));
() -> permissionManager.revokePrivilege("privilege1", null));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -628,24 +626,24 @@ public class PermissionManagerTest {
/**
* Verifies that
* {@link PermissionManager#revokePrivilege(java.lang.String, org.libreccm.security.Role, org.libreccm.core.CcmObject)}
* throws an {@link IllegalArgumentException} if called with {@code null}
* for the role to revoke the permission from.
* throws an {@link NullPointerException} if called with {@code null} for
* the role to revoke the permission from.
*
* @throws Throwable
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = NullPointerException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(NullPointerException.class)
@InSequence(345)
public void revokePermissionOnObjectFromRoleNull() throws Throwable {
final CcmObject object1 = ccmObjectRepository.findById(-20001L).get();
try {
shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege("privilege1",
null,
object1));
() -> permissionManager.revokePrivilege("privilege1",
null,
object1));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -659,19 +657,19 @@ public class PermissionManagerTest {
*
* @throws Throwable
*/
@Test(expected = IllegalArgumentException.class)
@Test(expected = NullPointerException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(NullPointerException.class)
@InSequence(350)
public void revokePermissionNullObject() throws Throwable {
final Role role1 = roleRepository.findByName("role1").get();
try {
shiro.getSystemUser().execute(
() -> permissionManager.revokePrivilege("privilege2",
role1,
null));
() -> permissionManager.revokePrivilege("privilege2",
role1,
null));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -686,18 +684,18 @@ public class PermissionManagerTest {
*/
@Test
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldMatchDataSet(
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-copy.yml",
excludeColumns = {"permission_id"})
value = "datasets/org/libreccm/security/PermissionManagerTest/"
+ "after-copy.yml",
excludeColumns = {"permission_id"})
@InSequence(400)
public void copyPermissions() throws Throwable {
final CcmObject object2 = ccmObjectRepository.findById(-20002L).get();
final CcmObject object3 = ccmObjectRepository.findById(-20003L).get();
shiro.getSystemUser().execute(
() -> permissionManager.copyPermissions(object2, object3));
() -> permissionManager.copyPermissions(object2, object3));
}
/**
@ -710,7 +708,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(410)
public void copyPermissionsNullSource() throws Throwable {
@ -718,7 +716,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.copyPermissions(null, object3));
() -> permissionManager.copyPermissions(null, object3));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -734,7 +732,7 @@ public class PermissionManagerTest {
*/
@Test(expected = IllegalArgumentException.class)
@UsingDataSet(
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
@ShouldThrowException(IllegalArgumentException.class)
@InSequence(420)
public void copyPermissionsNullTarget() throws Throwable {
@ -742,7 +740,7 @@ public class PermissionManagerTest {
try {
shiro.getSystemUser().execute(
() -> permissionManager.copyPermissions(object2, null));
() -> permissionManager.copyPermissions(object2, null));
} catch (ExecutionException ex) {
throw ex.getCause();
}
@ -758,9 +756,9 @@ public class PermissionManagerTest {
public void verifyListPrivileges() {
final List<String> corePrivileges = permissionManager
.listDefiniedPrivileges(CoreConstants.class);
.listDefiniedPrivileges(CoreConstants.class);
final List<String> catPrivileges = permissionManager
.listDefiniedPrivileges(CategorizationConstants.class);
.listDefiniedPrivileges(CategorizationConstants.class);
assertThat(corePrivileges, is(not(nullValue())));
assertThat(corePrivileges.isEmpty(), is(false));

View File

@ -47,8 +47,7 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
TaskComment.class,
TaskAssignment.class,
AssignableTask.class,
Workflow.class,
WorkflowTemplate.class
Workflow.class
});
}
@ -97,12 +96,6 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
final Workflow workflow2 = new Workflow();
workflow2.getName().addValue(Locale.ENGLISH, "Workflow 2");
final WorkflowTemplate template1 = new WorkflowTemplate();
template1.getName().addValue(Locale.ENGLISH, "Template 1");
final WorkflowTemplate template2 = new WorkflowTemplate();
template1.getName().addValue(Locale.ENGLISH, "Template 2");
final CcmObject object1 = new CcmObject();
object1.setDisplayName("Object 1");
@ -117,7 +110,6 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
.withPrefabValues(Group.class, group1, group2)
.withPrefabValues(User.class, user1, user2)
.withPrefabValues(Workflow.class, workflow1, workflow2)
.withPrefabValues(WorkflowTemplate.class, template1, template2)
.withPrefabValues(CcmObject.class, object1, object2);
}

View File

@ -46,7 +46,7 @@ create schema CCM_CORE;
create table CCM_CORE.CATEGORY_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -63,7 +63,7 @@ create schema CCM_CORE;
create table CCM_CORE.CATEGORY_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -111,7 +111,7 @@ create schema CCM_CORE;
create table CCM_CORE.DOMAIN_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -128,14 +128,14 @@ create schema CCM_CORE;
create table CCM_CORE.DOMAIN_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_COMPONENT_DESCRIPTIONS (
COMPONENT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (COMPONENT_ID, LOCALE)
);
@ -180,14 +180,14 @@ create schema CCM_CORE;
create table CCM_CORE.FORMBUILDER_DATA_QUERY_DESCRIPTIONS (
DATA_QUERY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (DATA_QUERY_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_DATA_QUERY_NAMES (
DATA_QUERY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (DATA_QUERY_ID, LOCALE)
);
@ -224,7 +224,7 @@ create schema CCM_CORE;
create table CCM_CORE.FORMBUILDER_OPTION_LABELS (
OPTION_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OPTION_ID, LOCALE)
);
@ -237,14 +237,14 @@ create schema CCM_CORE;
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_DESCRIPTIONS (
PROCESS_LISTENER_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PROCESS_LISTENER_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_NAMES (
PROCESS_LISTENER_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PROCESS_LISTENER_ID, LOCALE)
);
@ -403,14 +403,14 @@ create schema CCM_CORE;
create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS (
PAGE_MODEL_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PAGE_MODEL_ID, LOCALE)
);
create table CCM_CORE.PAGE_MODEL_TITLES (
PAGE_MODEL_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PAGE_MODEL_ID, LOCALE)
);
@ -436,7 +436,7 @@ create schema CCM_CORE;
PERMISSION_ID bigint not null,
CREATION_DATE timestamp,
CREATION_IP varchar(255),
granted_privilege varchar(255),
GRANTED_PRIVILEGE varchar(255),
INHERITED boolean,
CREATION_USER_ID bigint,
GRANTEE_ID bigint,
@ -473,21 +473,21 @@ create schema CCM_CORE;
create table CCM_CORE.RESOURCE_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.RESOURCE_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.RESOURCE_TYPE_DESCRIPTIONS (
RESOURCE_TYPE_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (RESOURCE_TYPE_ID, LOCALE)
);
@ -512,7 +512,7 @@ create schema CCM_CORE;
create table CCM_CORE.ROLE_DESCRIPTIONS (
ROLE_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (ROLE_ID, LOCALE)
);
@ -529,11 +529,11 @@ create schema CCM_CORE;
SETTING_ID bigint not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE double,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
SETTING_VALUE_LONG bigint,
SETTING_VALUE_DOUBLE double,
SETTING_VALUE_STRING varchar(1024),
primary key (SETTING_ID)
);
@ -544,7 +544,7 @@ create schema CCM_CORE;
create table CCM_CORE.SETTINGS_L10N_STR_VALUES (
ENTRY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (ENTRY_ID, LOCALE)
);
@ -593,14 +593,14 @@ create schema CCM_CORE;
create table CCM_CORE.WORKFLOW_DESCRIPTIONS (
WORKFLOW_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (WORKFLOW_ID, LOCALE)
);
create table CCM_CORE.WORKFLOW_NAMES (
WORKFLOW_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (WORKFLOW_ID, LOCALE)
);
@ -614,7 +614,7 @@ create schema CCM_CORE;
create table CCM_CORE.WORKFLOW_TASK_COMMENTS (
COMMENT_ID bigint not null,
COMMENT longvarchar,
COMMENT varchar(2147483647),
UUID varchar(255) not null,
AUTHOR_ID bigint,
TASK_ID bigint,
@ -628,14 +628,14 @@ create schema CCM_CORE;
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
TASK_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (TASK_ID, LOCALE)
);
create table CCM_CORE.WORKFLOW_TASK_LABELS (
TASK_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (TASK_ID, LOCALE)
);
@ -649,13 +649,9 @@ create schema CCM_CORE;
primary key (TASK_ID)
);
create table CCM_CORE.WORKFLOW_TEMPLATES (
WORKFLOW_ID bigint not null,
primary key (WORKFLOW_ID)
);
create table CCM_CORE.WORKFLOWS (
WORKFLOW_ID bigint not null,
abstract_workflow boolean,
ACTIVE boolean,
WORKFLOW_STATE varchar(255),
TASKS_STATE varchar(255),
@ -691,7 +687,8 @@ create schema CCM_CORE;
alter table CCM_CORE.WORKFLOWS
add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID);
create sequence hibernate_sequence start with 1 increment by 1;
create sequence hibernate_sequence start with 1 increment by 1;
alter table CCM_CORE.APPLICATIONS
add constraint FKatcp9ij6mbkx0nfeig1o6n3lm
@ -1014,7 +1011,7 @@ create sequence hibernate_sequence start with 1 increment by 1;
references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.PERMISSIONS
add constraint FKc1x3h1p3o20qiwmonpmva7t5i
add constraint FKg56ujjoe0j30pq579rf0l5yc6
foreign key (INHERITED_FROM_ID)
references CCM_CORE.CCM_OBJECTS;
@ -1198,17 +1195,12 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOW_TEMPLATES
add constraint FK8692vdme4yxnkj1m0k1dw74pk
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOWS
add constraint FKrm2yfrs6veoxoy304upq2wc64
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.WORKFLOWS
add constraint FKeixdxau4jebw682gd49tdbsjy
add constraint FK9ray5beiny6wm2mi0uwyecay2
foreign key (TEMPLATE_ID)
references CCM_CORE.WORKFLOW_TEMPLATES;
references CCM_CORE.WORKFLOWS;

View File

@ -2,7 +2,7 @@ drop schema if exists CCM_CORE cascade;
drop sequence if exists HIBERNATE_SEQUENCE;
create schema CCM_CORE;
create schema CCM_CORE;
create table CCM_CORE.APPLICATIONS (
APPLICATION_TYPE varchar(1024) not null,
@ -436,7 +436,7 @@ create schema CCM_CORE;
PERMISSION_ID int8 not null,
CREATION_DATE timestamp,
CREATION_IP varchar(255),
granted_privilege varchar(255),
GRANTED_PRIVILEGE varchar(255),
INHERITED boolean,
CREATION_USER_ID int8,
GRANTEE_ID int8,
@ -529,11 +529,11 @@ create schema CCM_CORE;
SETTING_ID int8 not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE float8,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
SETTING_VALUE_LONG int8,
SETTING_VALUE_DOUBLE float8,
SETTING_VALUE_STRING varchar(1024),
primary key (SETTING_ID)
);
@ -649,13 +649,9 @@ create schema CCM_CORE;
primary key (TASK_ID)
);
create table CCM_CORE.WORKFLOW_TEMPLATES (
WORKFLOW_ID int8 not null,
primary key (WORKFLOW_ID)
);
create table CCM_CORE.WORKFLOWS (
WORKFLOW_ID int8 not null,
abstract_workflow boolean,
ACTIVE boolean,
WORKFLOW_STATE varchar(255),
TASKS_STATE varchar(255),
@ -691,7 +687,8 @@ create schema CCM_CORE;
alter table CCM_CORE.WORKFLOWS
add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID);
create sequence hibernate_sequence start 1 increment 1;
create sequence hibernate_sequence start 1 increment 1;
alter table CCM_CORE.APPLICATIONS
add constraint FKatcp9ij6mbkx0nfeig1o6n3lm
@ -1014,7 +1011,7 @@ create sequence hibernate_sequence start 1 increment 1;
references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.PERMISSIONS
add constraint FKc1x3h1p3o20qiwmonpmva7t5i
add constraint FKg56ujjoe0j30pq579rf0l5yc6
foreign key (INHERITED_FROM_ID)
references CCM_CORE.CCM_OBJECTS;
@ -1198,17 +1195,12 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOW_TEMPLATES
add constraint FK8692vdme4yxnkj1m0k1dw74pk
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOWS
add constraint FKrm2yfrs6veoxoy304upq2wc64
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.WORKFLOWS
add constraint FKeixdxau4jebw682gd49tdbsjy
add constraint FK9ray5beiny6wm2mi0uwyecay2
foreign key (TEMPLATE_ID)
references CCM_CORE.WORKFLOW_TEMPLATES;
references CCM_CORE.WORKFLOWS;

View File

@ -48,7 +48,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.CATEGORY_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -65,7 +65,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.CATEGORY_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -81,7 +81,6 @@ CREATE SCHEMA ccm_shortcuts;
OBJECT_ID bigint not null,
REV integer not null,
REVTYPE tinyint,
REVEND integer,
DISPLAY_NAME varchar(255),
primary key (OBJECT_ID, REV)
);
@ -113,7 +112,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.DOMAIN_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
@ -130,14 +129,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.DOMAIN_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_COMPONENT_DESCRIPTIONS (
COMPONENT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (COMPONENT_ID, LOCALE)
);
@ -182,14 +181,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.FORMBUILDER_DATA_QUERY_DESCRIPTIONS (
DATA_QUERY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (DATA_QUERY_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_DATA_QUERY_NAMES (
DATA_QUERY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (DATA_QUERY_ID, LOCALE)
);
@ -226,7 +225,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.FORMBUILDER_OPTION_LABELS (
OPTION_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OPTION_ID, LOCALE)
);
@ -239,14 +238,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_DESCRIPTIONS (
PROCESS_LISTENER_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PROCESS_LISTENER_ID, LOCALE)
);
create table CCM_CORE.FORMBUILDER_PROCESS_LISTENER_NAMES (
PROCESS_LISTENER_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PROCESS_LISTENER_ID, LOCALE)
);
@ -405,14 +404,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.PAGE_MODEL_DESCRIPTIONS (
PAGE_MODEL_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PAGE_MODEL_ID, LOCALE)
);
create table CCM_CORE.PAGE_MODEL_TITLES (
PAGE_MODEL_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (PAGE_MODEL_ID, LOCALE)
);
@ -438,7 +437,7 @@ CREATE SCHEMA ccm_shortcuts;
PERMISSION_ID bigint not null,
CREATION_DATE timestamp,
CREATION_IP varchar(255),
granted_privilege varchar(255),
GRANTED_PRIVILEGE varchar(255),
INHERITED boolean,
CREATION_USER_ID bigint,
GRANTEE_ID bigint,
@ -475,21 +474,21 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.RESOURCE_DESCRIPTIONS (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.RESOURCE_TITLES (
OBJECT_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (OBJECT_ID, LOCALE)
);
create table CCM_CORE.RESOURCE_TYPE_DESCRIPTIONS (
RESOURCE_TYPE_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (RESOURCE_TYPE_ID, LOCALE)
);
@ -514,7 +513,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.ROLE_DESCRIPTIONS (
ROLE_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (ROLE_ID, LOCALE)
);
@ -531,11 +530,11 @@ CREATE SCHEMA ccm_shortcuts;
SETTING_ID bigint not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE double,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_LONG bigint,
SETTING_VALUE_BIG_DECIMAL decimal(19,2),
primary key (SETTING_ID)
);
@ -546,7 +545,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.SETTINGS_L10N_STR_VALUES (
ENTRY_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (ENTRY_ID, LOCALE)
);
@ -595,14 +594,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.WORKFLOW_DESCRIPTIONS (
WORKFLOW_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (WORKFLOW_ID, LOCALE)
);
create table CCM_CORE.WORKFLOW_NAMES (
WORKFLOW_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (WORKFLOW_ID, LOCALE)
);
@ -616,7 +615,7 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.WORKFLOW_TASK_COMMENTS (
COMMENT_ID bigint not null,
COMMENT longvarchar,
COMMENT varchar(2147483647),
UUID varchar(255) not null,
AUTHOR_ID bigint,
TASK_ID bigint,
@ -630,14 +629,14 @@ CREATE SCHEMA ccm_shortcuts;
create table CCM_CORE.WORKFLOW_TASK_DESCRIPTIONS (
TASK_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (TASK_ID, LOCALE)
);
create table CCM_CORE.WORKFLOW_TASK_LABELS (
TASK_ID bigint not null,
LOCALIZED_VALUE longvarchar,
LOCALIZED_VALUE varchar(2147483647),
LOCALE varchar(255) not null,
primary key (TASK_ID, LOCALE)
);
@ -651,13 +650,9 @@ CREATE SCHEMA ccm_shortcuts;
primary key (TASK_ID)
);
create table CCM_CORE.WORKFLOW_TEMPLATES (
WORKFLOW_ID bigint not null,
primary key (WORKFLOW_ID)
);
create table CCM_CORE.WORKFLOWS (
WORKFLOW_ID bigint not null,
abstract_workflow boolean,
ACTIVE boolean,
WORKFLOW_STATE varchar(255),
TASKS_STATE varchar(255),
@ -693,7 +688,18 @@ CREATE SCHEMA ccm_shortcuts;
alter table CCM_CORE.WORKFLOWS
add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID);
create sequence hibernate_sequence start with 1 increment by 1;
create table CCM_SHORTCUTS.SHORTCUTS (
SHORTCUT_ID bigint not null,
REDIRECT varchar(1024),
URL_KEY varchar(1024),
primary key (SHORTCUT_ID)
);
alter table CCM_SHORTCUTS.SHORTCUTS
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
create sequence hibernate_sequence start with 1 increment by 1;
alter table CCM_CORE.APPLICATIONS
add constraint FKatcp9ij6mbkx0nfeig1o6n3lm
@ -750,11 +756,6 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CORE.CCM_OBJECTS_AUD
add constraint FKo5s37ctcdny7tmewjwv7705h5
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CORE.DIGESTS
add constraint FKc53g09agnye3w1v4euy3e0gsi
foreign key (FROM_PARTY_ID)
@ -1016,7 +1017,7 @@ create sequence hibernate_sequence start with 1 increment by 1;
references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.PERMISSIONS
add constraint FKc1x3h1p3o20qiwmonpmva7t5i
add constraint FKg56ujjoe0j30pq579rf0l5yc6
foreign key (INHERITED_FROM_ID)
references CCM_CORE.CCM_OBJECTS;
@ -1200,27 +1201,12 @@ create sequence hibernate_sequence start with 1 increment by 1;
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOW_TEMPLATES
add constraint FK8692vdme4yxnkj1m0k1dw74pk
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOWS
add constraint FKrm2yfrs6veoxoy304upq2wc64
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.WORKFLOWS
add constraint FKeixdxau4jebw682gd49tdbsjy
add constraint FK9ray5beiny6wm2mi0uwyecay2
foreign key (TEMPLATE_ID)
references CCM_CORE.WORKFLOW_TEMPLATES;
create table CCM_SHORTCUTS.SHORTCUTS (
SHORTCUT_ID bigint not null,
REDIRECT varchar(1024),
URL_KEY varchar(1024),
primary key (SHORTCUT_ID)
);
alter table CCM_SHORTCUTS.SHORTCUTS
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
references CCM_CORE.WORKFLOWS;

View File

@ -81,7 +81,6 @@ create table CCM_CORE.APPLICATIONS (
OBJECT_ID int8 not null,
REV int4 not null,
REVTYPE int2,
REVEND int4,
DISPLAY_NAME varchar(255),
primary key (OBJECT_ID, REV)
);
@ -438,7 +437,7 @@ create table CCM_CORE.APPLICATIONS (
PERMISSION_ID int8 not null,
CREATION_DATE timestamp,
CREATION_IP varchar(255),
granted_privilege varchar(255),
GRANTED_PRIVILEGE varchar(255),
INHERITED boolean,
CREATION_USER_ID int8,
GRANTEE_ID int8,
@ -531,11 +530,11 @@ create table CCM_CORE.APPLICATIONS (
SETTING_ID int8 not null,
CONFIGURATION_CLASS varchar(512) not null,
NAME varchar(512) not null,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_DOUBLE float8,
SETTING_VALUE_STRING varchar(1024),
SETTING_VALUE_BOOLEAN boolean,
SETTING_VALUE_LONG int8,
SETTING_VALUE_BIG_DECIMAL numeric(19, 2),
primary key (SETTING_ID)
);
@ -651,13 +650,9 @@ create table CCM_CORE.APPLICATIONS (
primary key (TASK_ID)
);
create table CCM_CORE.WORKFLOW_TEMPLATES (
WORKFLOW_ID int8 not null,
primary key (WORKFLOW_ID)
);
create table CCM_CORE.WORKFLOWS (
WORKFLOW_ID int8 not null,
abstract_workflow boolean,
ACTIVE boolean,
WORKFLOW_STATE varchar(255),
TASKS_STATE varchar(255),
@ -693,7 +688,18 @@ create table CCM_CORE.APPLICATIONS (
alter table CCM_CORE.WORKFLOWS
add constraint UK_o113id7d1cxql0edsrohlnn9x unique (UUID);
create sequence hibernate_sequence start 1 increment 1;
create table CCM_SHORTCUTS.SHORTCUTS (
SHORTCUT_ID int8 not null,
REDIRECT varchar(1024),
URL_KEY varchar(1024),
primary key (SHORTCUT_ID)
);
alter table CCM_SHORTCUTS.SHORTCUTS
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
create sequence hibernate_sequence start 1 increment 1;
alter table CCM_CORE.APPLICATIONS
add constraint FKatcp9ij6mbkx0nfeig1o6n3lm
@ -750,11 +756,6 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (REV)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CORE.CCM_OBJECTS_AUD
add constraint FKo5s37ctcdny7tmewjwv7705h5
foreign key (REVEND)
references CCM_CORE.CCM_REVISIONS;
alter table CCM_CORE.DIGESTS
add constraint FKc53g09agnye3w1v4euy3e0gsi
foreign key (FROM_PARTY_ID)
@ -1016,7 +1017,7 @@ create sequence hibernate_sequence start 1 increment 1;
references CCM_CORE.CCM_ROLES;
alter table CCM_CORE.PERMISSIONS
add constraint FKc1x3h1p3o20qiwmonpmva7t5i
add constraint FKg56ujjoe0j30pq579rf0l5yc6
foreign key (INHERITED_FROM_ID)
references CCM_CORE.CCM_OBJECTS;
@ -1200,28 +1201,12 @@ create sequence hibernate_sequence start 1 increment 1;
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOW_TEMPLATES
add constraint FK8692vdme4yxnkj1m0k1dw74pk
foreign key (WORKFLOW_ID)
references CCM_CORE.WORKFLOWS;
alter table CCM_CORE.WORKFLOWS
add constraint FKrm2yfrs6veoxoy304upq2wc64
foreign key (OBJECT_ID)
references CCM_CORE.CCM_OBJECTS;
alter table CCM_CORE.WORKFLOWS
add constraint FKeixdxau4jebw682gd49tdbsjy
add constraint FK9ray5beiny6wm2mi0uwyecay2
foreign key (TEMPLATE_ID)
references CCM_CORE.WORKFLOW_TEMPLATES;
create table CCM_SHORTCUTS.SHORTCUTS (
SHORTCUT_ID int8 not null,
REDIRECT varchar(1024),
URL_KEY varchar(1024),
primary key (SHORTCUT_ID)
);
alter table CCM_SHORTCUTS.SHORTCUTS
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
references CCM_CORE.WORKFLOWS;