diff --git a/ccm-cms/src/main/java/org/librecms/workflow/CmsTask.java b/ccm-cms/src/main/java/org/librecms/workflow/CmsTask.java deleted file mode 100644 index 5c1327261..000000000 --- a/ccm-cms/src/main/java/org/librecms/workflow/CmsTask.java +++ /dev/null @@ -1,102 +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.librecms.workflow; - -import org.libreccm.workflow.AssignableTask; -import org.librecms.contentsection.ContentItem; - -import java.io.Serializable; -import java.util.Objects; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.Table; - -import static org.librecms.CmsConstants.*; - -/** - * A special tasks for {@link ContentItem}s. - * - * @author Jens Pelzetter - */ -@Entity -@Table(name = "WORKFLOW_TASKS", schema = DB_SCHEMA) -public class CmsTask extends AssignableTask implements Serializable { - - private static final long serialVersionUID = -3988352366529930659L; - - /** - * The type of the task. - */ - @Column(name = "TASK_TYPE") - @Enumerated(EnumType.STRING) - private CmsTaskType taskType; - - public CmsTaskType getTaskType() { - return taskType; - } - - public void setTaskType(final CmsTaskType taskType) { - this.taskType = taskType; - } - - @Override - public int hashCode() { - int hash = super.hashCode(); - hash = 79 * hash + Objects.hashCode(taskType); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!super.equals(obj)) { - return false; - } - - if (obj instanceof CmsTask) { - return false; - } - final CmsTask other = (CmsTask) obj; - if (!other.canEqual(this)) { - return false; - } - - return Objects.equals(taskType, other.getTaskType()); - } - - @Override - public boolean canEqual(final Object obj) { - return obj instanceof CmsTask; - } - - @Override - public String toString(final String data) { - return super.toString(String.format(", taskType = %s%s", - Objects.toString(taskType), - data)); - } -} diff --git a/ccm-cms/src/main/java/org/librecms/workflow/CmsTaskManager.java b/ccm-cms/src/main/java/org/librecms/workflow/CmsTaskManager.java deleted file mode 100644 index e67e3b2ea..000000000 --- a/ccm-cms/src/main/java/org/librecms/workflow/CmsTaskManager.java +++ /dev/null @@ -1,61 +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.librecms.workflow; - -import com.arsdigita.cms.workflow.TaskURLGenerator; - -import org.libreccm.core.UnexpectedErrorException; -import org.librecms.contentsection.ContentItem; - -import java.lang.reflect.InvocationTargetException; - -import javax.enterprise.context.RequestScoped; - -/** - * Manager for {@link CmsTask}s. - * - * @author Jens Pelzetter - */ -@RequestScoped -public class CmsTaskManager { - - /** - * Retrieves the URL for finishing the task for a certain {@link ContentItem}. - * - * @param item The item. - * @param task The task. - * @return The finish URL. - */ - public String getFinishUrl(final ContentItem item, final CmsTask task) { - final Class urlGeneratorClass = task - .getTaskType().getUrlGenerator(); - final TaskURLGenerator urlGenerator; - try { - urlGenerator = urlGeneratorClass.getDeclaredConstructor().newInstance(); - } catch (IllegalAccessException - | InstantiationException - | NoSuchMethodException - | InvocationTargetException ex) { - throw new UnexpectedErrorException(ex); - } - - return urlGenerator.generateURL(item.getObjectId(), task.getTaskId()); - } - -} diff --git a/ccm-cms/src/main/java/org/librecms/workflow/CmsTaskType.java b/ccm-cms/src/main/java/org/librecms/workflow/CmsTaskType.java deleted file mode 100644 index 30e727d5c..000000000 --- a/ccm-cms/src/main/java/org/librecms/workflow/CmsTaskType.java +++ /dev/null @@ -1,56 +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.librecms.workflow; - -import com.arsdigita.cms.workflow.AuthoringTaskURLGenerator; -import com.arsdigita.cms.workflow.DeployTaskURLGenerator; -import com.arsdigita.cms.workflow.EditingTaskURLGenerator; -import com.arsdigita.cms.workflow.TaskURLGenerator; - -import org.librecms.contentsection.privileges.ItemPrivileges; - -/** - * Possible types of a {@link CmsTask}. - * - * @author Jens Pelzetter - */ -public enum CmsTaskType { - - AUTHOR(AuthoringTaskURLGenerator.class, ItemPrivileges.EDIT), - EDIT(EditingTaskURLGenerator.class, ItemPrivileges.APPROVE), - DEPLOY(DeployTaskURLGenerator.class, ItemPrivileges.PUBLISH); - - private final Class urlGenerator; - private final String privilege; - - private CmsTaskType(final Class urlGenerator, - final String privilege) { - this.urlGenerator = urlGenerator; - this.privilege = privilege; - } - - public Class getUrlGenerator() { - return urlGenerator; - } - - public String getPrivilege() { - return privilege; - } - -}