From ab1b9cecdee2027884f72b199409e663a948ed18 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 17 Jan 2018 11:01:18 -0600 Subject: [PATCH] #13395 CopyContentlet done --- .../workflows/business/CopyActionletTest.java | 185 ++++++++++++++++++ .../business/ESContentletAPIImpl.java | 3 +- .../main/java/com/dotcms/util/Converter.java | 1 + .../main/java/com/dotcms/util/Delegate.java | 1 + .../com/dotcms/util/ReturnableDelegate.java | 1 + .../java/com/dotcms/util/VoidDelegate.java | 1 + .../contentlet/business/ContentletAPI.java | 20 +- .../business/ContentletAPIInterceptor.java | 24 +++ .../business/ContentletAPIPostHook.java | 15 +- .../business/ContentletAPIPreHook.java | 19 +- .../workflows/actionlet/CopyActionlet.java | 129 ++++++++++++ .../actionlet/event/CopyActionletEvent.java | 24 +++ .../workflows/business/WorkflowAPIImpl.java | 3 +- 13 files changed, 421 insertions(+), 5 deletions(-) create mode 100644 dotCMS/src/integration-test/java/com/dotmarketing/portlets/workflows/business/CopyActionletTest.java create mode 100644 dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/CopyActionlet.java create mode 100644 dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/event/CopyActionletEvent.java diff --git a/dotCMS/src/integration-test/java/com/dotmarketing/portlets/workflows/business/CopyActionletTest.java b/dotCMS/src/integration-test/java/com/dotmarketing/portlets/workflows/business/CopyActionletTest.java new file mode 100644 index 000000000000..6574a9e0de11 --- /dev/null +++ b/dotCMS/src/integration-test/java/com/dotmarketing/portlets/workflows/business/CopyActionletTest.java @@ -0,0 +1,185 @@ +package com.dotmarketing.portlets.workflows.business; + +import com.dotcms.contenttype.business.ContentTypeAPI; +import com.dotcms.contenttype.model.field.DataTypes; +import com.dotcms.contenttype.model.field.Field; +import com.dotcms.contenttype.model.field.FieldBuilder; +import com.dotcms.contenttype.model.field.TextField; +import com.dotcms.contenttype.model.type.BaseContentType; +import com.dotcms.contenttype.model.type.ContentType; +import com.dotcms.contenttype.model.type.ContentTypeBuilder; +import com.dotcms.contenttype.transform.contenttype.StructureTransformer; +import com.dotcms.system.event.local.model.EventSubscriber; +import com.dotcms.util.IntegrationTestInitService; +import com.dotmarketing.beans.Host; +import com.dotmarketing.business.APILocator; +import com.dotmarketing.exception.AlreadyExistException; +import com.dotmarketing.exception.DotDataException; +import com.dotmarketing.exception.DotSecurityException; +import com.dotmarketing.portlets.contentlet.business.ContentletAPI; +import com.dotmarketing.portlets.contentlet.model.Contentlet; +import com.dotmarketing.portlets.folders.business.FolderAPI; +import com.dotmarketing.portlets.workflows.actionlet.CopyActionlet; +import com.dotmarketing.portlets.workflows.actionlet.SaveContentActionlet; +import com.dotmarketing.portlets.workflows.actionlet.event.CopyActionletEvent; +import com.dotmarketing.portlets.workflows.model.WorkflowProcessor; +import com.dotmarketing.util.UUIDGenerator; +import com.liferay.portal.model.User; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +public class CopyActionletTest extends BaseWorkflowIntegrationTest { + + private static CreateSchemeStepActionResult schemeStepActionResult = null; + private static WorkflowAPI workflowAPI = null; + private static ContentletAPI contentletAPI = null; + private static ContentType type = null; + private static Contentlet contentlet = null; + private static Contentlet contentletCopy = null; + + + @BeforeClass + public static void prepare() throws Exception { + //Setting web app environment + + IntegrationTestInitService.getInstance().init(); + CopyActionletTest.workflowAPI = APILocator.getWorkflowAPI(); + final ContentTypeAPI contentTypeAPI = APILocator.getContentTypeAPI(APILocator.systemUser()); + CopyActionletTest.contentletAPI = APILocator.getContentletAPI(); + + // creates the scheme and actions + CopyActionletTest.schemeStepActionResult = CopyActionletTest.createSchemeStepActionActionlet + ("CopyActionlet" + UUIDGenerator.generateUuid(), "step1", "action1", CopyActionlet.class); + + // creates the type to trigger the scheme + CopyActionletTest.createTestType(contentTypeAPI); + + // associated the scheme to the type + CopyActionletTest.workflowAPI.saveSchemesForStruct(new StructureTransformer(CopyActionletTest.type).asStructure(), + Arrays.asList(CopyActionletTest.schemeStepActionResult.getScheme())); + + } + + private static void createTestType(final ContentTypeAPI contentTypeAPI) throws DotDataException, DotSecurityException { + + CopyActionletTest.type = contentTypeAPI.save( + ContentTypeBuilder.builder(BaseContentType.CONTENT.immutableClass()) + .expireDateVar(null).folder(FolderAPI.SYSTEM_FOLDER).host(Host.SYSTEM_HOST) + .description("DotCopyActionletTest...") + .name("DotCopyActionletTest").owner(APILocator.systemUser().toString()) + .variable("DotCopyActionletTest").build()); + + final List fields = new ArrayList<>(CopyActionletTest.type.fields()); + + fields.add(FieldBuilder.builder(TextField.class).name("title").variable("title") + .contentTypeId(CopyActionletTest.type.id()).dataType(DataTypes.TEXT).indexed(true).build()); + fields.add(FieldBuilder.builder(TextField.class).name("txt").variable("txt") + .contentTypeId(CopyActionletTest.type.id()).dataType(DataTypes.TEXT).indexed(true).build()); + + CopyActionletTest.type = contentTypeAPI.save(CopyActionletTest.type, fields); + } + + /** + * Remove the content type and workflows created + */ + @AfterClass + public static void cleanup() throws DotDataException, DotSecurityException, AlreadyExistException { + + try { + + if (null != CopyActionletTest.contentlet) { + + CopyActionletTest.contentletAPI.delete(CopyActionletTest.contentlet, APILocator.systemUser(), false); + } + + if (null != CopyActionletTest.contentletCopy) { + + CopyActionletTest.contentletAPI.delete(CopyActionletTest.contentletCopy, APILocator.systemUser(), false); + } + } finally { + + try { + + if (null != CopyActionletTest.schemeStepActionResult) { + + CopyActionletTest.cleanScheme(CopyActionletTest.schemeStepActionResult.getScheme()); + } + } finally { + + if (null != CopyActionletTest.type) { + + ContentTypeAPI contentTypeAPI = APILocator.getContentTypeAPI(APILocator.systemUser()); + contentTypeAPI.delete(CopyActionletTest.type); + } + } + } + } // cleanup + + @Test + public void saveContentTest() throws DotDataException, DotSecurityException { + + final long languageId = APILocator.getLanguageAPI().getDefaultLanguage().getId(); + final Contentlet contentlet = new Contentlet(); + final User user = APILocator.systemUser(); + contentlet.setContentTypeId(CopyActionletTest.type.id()); + contentlet.setOwner(APILocator.systemUser().toString()); + contentlet.setModDate(new Date()); + contentlet.setLanguageId(languageId); + contentlet.setStringProperty("title", "Test Save"); + contentlet.setStringProperty("txt", "Test Save Text"); + contentlet.setHost(Host.SYSTEM_HOST); + contentlet.setFolder(FolderAPI.SYSTEM_FOLDER); + + APILocator.getLocalSystemEventsAPI().subscribe(CopyActionletEvent.class, new EventSubscriber() { + @Override + public void notify(CopyActionletEvent event) { + + contentletCopy = event.getCopyContentlet(); + } + }); + + // first save + final Contentlet contentlet1 = CopyActionletTest.contentletAPI.checkin(contentlet, user, false); + final String firstIdentifier = contentlet1.getIdentifier(); + final String firstInode = contentlet1.getInode(); + + CopyActionletTest.contentlet = contentlet1; + + // triggering the copy action + contentlet1.setStringProperty(Contentlet.WORKFLOW_ACTION_KEY, + this.schemeStepActionResult.getAction().getId()); + contentlet1.setBoolProperty(CopyActionlet.NOTIFY_SYNC_COPY_EVENT, + true); + + final WorkflowProcessor processor = + CopyActionletTest.workflowAPI.fireWorkflowPreCheckin(contentlet1, user); + + CopyActionletTest.workflowAPI.fireWorkflowPostCheckin(processor); + + Assert.assertNotNull(contentletCopy); + Assert.assertNotNull(contentletCopy.getIdentifier()); + Assert.assertNotNull(contentletCopy.getInode()); + contentletAPI.isInodeIndexed(contentletCopy.getInode()); + + final Contentlet contentlet2 = CopyActionletTest.contentletAPI.findContentletByIdentifier + (CopyActionletTest.contentletCopy.getIdentifier(), + false, languageId, user, false); + + // the contentlet save by the action must be not null, should has a new version. + Assert.assertNotNull(contentlet2); + Assert.assertNotNull(contentlet2.getIdentifier()); + Assert.assertNotNull(contentlet2.getInode()); + Assert.assertFalse (contentlet2.getIdentifier().equals(firstIdentifier)); + Assert.assertFalse (contentlet2.getInode().equals(firstInode)); + Assert.assertEquals ("Test Save", contentlet2.getStringProperty("title")); + Assert.assertEquals ("Test Save Text", contentlet2.getStringProperty("txt")); + + } +} \ No newline at end of file diff --git a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java index 37db0e3f55d3..273d4e27c570 100644 --- a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java @@ -5014,7 +5014,8 @@ public List> DBSearch(Query query, User user,boolean r * @throws DotContentletStateException * The contentlet object could not be saved. */ - private Contentlet copyContentlet(Contentlet contentletToCopy, Host host, Folder folder, User user, final String copySuffix, boolean respectFrontendRoles) throws DotDataException, DotSecurityException, DotContentletStateException { + @Override + public Contentlet copyContentlet(Contentlet contentletToCopy, Host host, Folder folder, User user, final String copySuffix, boolean respectFrontendRoles) throws DotDataException, DotSecurityException, DotContentletStateException { Contentlet resultContentlet = new Contentlet(); String newIdentifier = Strings.EMPTY; ArrayList versionsToCopy = new ArrayList(); diff --git a/dotCMS/src/main/java/com/dotcms/util/Converter.java b/dotCMS/src/main/java/com/dotcms/util/Converter.java index b99ccbdb4f20..f2878d85d379 100644 --- a/dotCMS/src/main/java/com/dotcms/util/Converter.java +++ b/dotCMS/src/main/java/com/dotcms/util/Converter.java @@ -9,6 +9,7 @@ * @version 3.7 * @since Jun 8, 2016 */ +@FunctionalInterface public interface Converter extends Serializable { /** diff --git a/dotCMS/src/main/java/com/dotcms/util/Delegate.java b/dotCMS/src/main/java/com/dotcms/util/Delegate.java index bcbe289380d2..ccbbf33a64b4 100644 --- a/dotCMS/src/main/java/com/dotcms/util/Delegate.java +++ b/dotCMS/src/main/java/com/dotcms/util/Delegate.java @@ -24,6 +24,7 @@ * @since Jul 13, 2016 * */ +@FunctionalInterface public interface Delegate { /** diff --git a/dotCMS/src/main/java/com/dotcms/util/ReturnableDelegate.java b/dotCMS/src/main/java/com/dotcms/util/ReturnableDelegate.java index f6330002c4b1..3ed8ec14a17e 100644 --- a/dotCMS/src/main/java/com/dotcms/util/ReturnableDelegate.java +++ b/dotCMS/src/main/java/com/dotcms/util/ReturnableDelegate.java @@ -4,6 +4,7 @@ * Returnable delegate without any parameter. * @author jsanca */ +@FunctionalInterface public interface ReturnableDelegate { /** diff --git a/dotCMS/src/main/java/com/dotcms/util/VoidDelegate.java b/dotCMS/src/main/java/com/dotcms/util/VoidDelegate.java index 1416ba7f0ff5..96883c2d6cff 100644 --- a/dotCMS/src/main/java/com/dotcms/util/VoidDelegate.java +++ b/dotCMS/src/main/java/com/dotcms/util/VoidDelegate.java @@ -27,6 +27,7 @@ * @since Jul 13, 2016 * */ +@FunctionalInterface public interface VoidDelegate { /** diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPI.java b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPI.java index 26051abd67da..0e8426304c28 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPI.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPI.java @@ -247,7 +247,25 @@ public Contentlet copyContentlet(Contentlet contentlet, Host host, User user, bo * @throws DotContentletStateException */ public Contentlet copyContentlet(Contentlet contentlet, Folder folder, User user, boolean appendCopyToFileName, boolean respectFrontendRoles) throws DotDataException, DotSecurityException, DotContentletStateException; - + + /** + * Copies a contentlet, including all its fields including binary files, image and file fields are pointers and the are preserved as the are + * so if source contentlet points to image A and resulting new contentlet will point to same image A as well, also copies source permissions. + * And moves the the new piece of content to the given folder. CopySuffix will be to append suffix to the file name. + * + * @param contentletToCopy + * @param host + * @param folder + * @param user + * @param copySuffix + * @param respectFrontendRoles + * @return Contentlet + * @throws DotDataException + * @throws DotSecurityException + * @throws DotContentletStateException + */ + Contentlet copyContentlet(Contentlet contentletToCopy, Host host, Folder folder, User user, final String copySuffix, boolean respectFrontendRoles) throws DotDataException, DotSecurityException, DotContentletStateException; + /** * The search here takes a lucene query and pulls Contentlets for you. You can pass sortBy as null if you do not * have a field to sort by. limit should be 0 if no limit and the offset should be -1 is you are not paginating. diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIInterceptor.java b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIInterceptor.java index e50b6907f0bf..973abaff8bbc 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIInterceptor.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIInterceptor.java @@ -1863,6 +1863,30 @@ public Contentlet copyContentlet(Contentlet contentlet, Folder folder, User user return c; } + @Override + public Contentlet copyContentlet(final Contentlet contentletToCopy, + final Host host, final Folder folder, final User user, final String copySuffix, + final boolean respectFrontendRoles) throws DotDataException, DotSecurityException, DotContentletStateException { + + for (ContentletAPIPreHook pre : preHooks) { + + final boolean preResult = pre.copyContentlet(contentletToCopy, host, folder, user, copySuffix, respectFrontendRoles); + if(!preResult) { + Logger.error(this, "The following prehook failed " + pre.getClass().getName()); + throw new DotRuntimeException("The following prehook failed " + pre.getClass().getName()); + } + } + + final Contentlet copiedContentlet = + this.conAPI.copyContentlet(contentletToCopy, host, folder, user, copySuffix, respectFrontendRoles); + + for(ContentletAPIPostHook post : postHooks) { + post.copyContentlet(contentletToCopy, host, folder, user, copySuffix, respectFrontendRoles, copiedContentlet); + } + + return copiedContentlet; + } + @Override public boolean isInodeIndexed(String inode) { for(ContentletAPIPreHook pre : preHooks){ diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIPostHook.java b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIPostHook.java index 8ab69ca14878..f98ef677cb6e 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIPostHook.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIPostHook.java @@ -172,7 +172,20 @@ public default void copyContentlet(Contentlet currentContentlet, Folder folder, * @param returnValue - value returned by primary API Method */ public default void copyContentlet(Contentlet currentContentlet, Folder folder, User user, boolean appendCopyToFileName, boolean respectFrontendRoles,Contentlet returnValue){} - + + /** + * Makes a copy of a content. + * @param contentletToCopy + * @param host + * @param folder + * @param user + * @param copySuffix + * @param respectFrontendRoles + * @param returnValue - value returned by primary API Method + */ + public default void copyContentlet(final Contentlet contentletToCopy, + final Host host, final Folder folder, final User user, final String copySuffix, + final boolean respectFrontendRoles, Contentlet returnValue) {} /** * The search here takes a lucene query and pulls Contentlets for you. You can pass sortBy as null if you do not * have a field to sort by. limit should be 0 if no limit and the offset should be -1 is you are not paginating. diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIPreHook.java b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIPreHook.java index dce7cbfde33b..ac66c93633a5 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIPreHook.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/business/ContentletAPIPreHook.java @@ -198,7 +198,24 @@ public default boolean copyContentlet(Contentlet currentContentlet, Folder folde public default boolean copyContentlet(Contentlet currentContentlet, Folder folder, User user, boolean appendCopyToFileName, boolean respectFrontendRoles){ return true; } - + + /** + * Make a copye of a contentlet which the copySuffix to rename the filename + suffix. + * @param contentletToCopy + * @param host + * @param folder + * @param user + * @param copySuffix + * @param respectFrontendRoles + * @return + */ + public default boolean copyContentlet(final Contentlet contentletToCopy, + final Host host, final Folder folder, final User user, final String copySuffix, + final boolean respectFrontendRoles) { + return true; + } + + /** * The search here takes a lucene query and pulls Contentlets for you. You can pass sortBy as null if you do not * have a field to sort by. limit should be 0 if no limit and the offset should be -1 is you are not paginating. diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/CopyActionlet.java b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/CopyActionlet.java new file mode 100644 index 000000000000..f5bb37a93d71 --- /dev/null +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/CopyActionlet.java @@ -0,0 +1,129 @@ +package com.dotmarketing.portlets.workflows.actionlet; + + +import com.dotcms.system.event.local.business.LocalSystemEventsAPI; +import com.dotmarketing.beans.Host; +import com.dotmarketing.beans.Identifier; +import com.dotmarketing.business.APILocator; +import com.dotmarketing.exception.DotDataException; +import com.dotmarketing.exception.DotSecurityException; +import com.dotmarketing.portlets.contentlet.business.ContentletAPI; +import com.dotmarketing.portlets.contentlet.business.DotContentletStateException; +import com.dotmarketing.portlets.contentlet.business.DotContentletValidationException; +import com.dotmarketing.portlets.contentlet.business.HostAPI; +import com.dotmarketing.portlets.contentlet.model.Contentlet; +import com.dotmarketing.portlets.folders.business.FolderAPI; +import com.dotmarketing.portlets.workflows.actionlet.event.CopyActionletEvent; +import com.dotmarketing.portlets.workflows.model.WorkflowActionClassParameter; +import com.dotmarketing.portlets.workflows.model.WorkflowActionFailureException; +import com.dotmarketing.portlets.workflows.model.WorkflowActionletParameter; +import com.dotmarketing.portlets.workflows.model.WorkflowProcessor; +import com.dotmarketing.util.Logger; +import com.liferay.portal.model.User; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Copy the edited contentlet + * @author jsanca + */ +public class CopyActionlet extends WorkFlowActionlet { + + private static final long serialVersionUID = 1L; + public static final String NOTIFY_SYNC_COPY_EVENT = "notify.sync.copy.event"; + private final HostAPI hostAPI = APILocator.getHostAPI(); + private final FolderAPI folderAPI = APILocator.getFolderAPI(); + private final ContentletAPI contentletAPI = APILocator.getContentletAPI(); + private final LocalSystemEventsAPI localSystemEventsAPI = APILocator.getLocalSystemEventsAPI(); + + + + @Override + public List getParameters() { + return Collections.emptyList(); + } + + @Override + public String getName() { + return "Copy Contentlet"; + } + + @Override + public String getHowTo() { + return "This workflow actionlet copies the edited contentlet "; + } + + @Override + public void executePreAction(final WorkflowProcessor processor, + final Map params) + throws WorkflowActionFailureException, DotContentletValidationException { + + final Contentlet contentlet = processor.getContentlet(); + + try { + + if (!contentlet.isLocked()) { + + this.performCopy(contentlet, processor.getUser()); + } + } catch (DotContentletStateException | DotDataException | DotSecurityException | IOException e) { + + Logger.error(this, e.getMessage(), e); + throw new WorkflowActionFailureException(e.getMessage(), e); + } + } // executePreAction. + + @Override + public void executeAction(final WorkflowProcessor processor, + final Map params) + throws WorkflowActionFailureException { + + final Contentlet contentlet = processor.getContentlet(); + + try { + + if (contentlet.isLocked()) { + + this.performCopy(contentlet, processor.getUser()); + } + } catch (DotContentletStateException | DotDataException | DotSecurityException | IOException e) { + + Logger.error(this, e.getMessage(), e); + throw new WorkflowActionFailureException(e.getMessage(), e); + } + } // executeAction. + + private void performCopy(final Contentlet contentlet, + final User user) throws DotDataException, DotSecurityException, IOException { + + Contentlet copyContentlet = null; + + if (contentlet.isFileAsset()) { + + final Identifier contIdentifier = APILocator.getIdentifierAPI().find(contentlet); + Host host = this.hostAPI.find(contentlet.getHost(), user, false); + + host = (host == null)? new Host(): host; + copyContentlet = this.contentletAPI.copyContentlet(contentlet, host, + this.folderAPI.findFolderByPath(contIdentifier.getParentPath(), host, user, false), + user, new StringBuilder("_copy_").append(System.currentTimeMillis()).toString(), false); + } else { + + copyContentlet = this.contentletAPI.copyContentlet(contentlet, user, false); + } + + if (null != copyContentlet) { + + if (contentlet.getMap().containsKey(NOTIFY_SYNC_COPY_EVENT) && contentlet.getBoolProperty(NOTIFY_SYNC_COPY_EVENT)) { // for testing + + this.localSystemEventsAPI.notify(new CopyActionletEvent(contentlet, copyContentlet)); + } else { + this.localSystemEventsAPI.asyncNotify(new CopyActionletEvent(contentlet, copyContentlet)); + } + } + } // performCopy. + +} diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/event/CopyActionletEvent.java b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/event/CopyActionletEvent.java new file mode 100644 index 000000000000..0a9d8188c904 --- /dev/null +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/event/CopyActionletEvent.java @@ -0,0 +1,24 @@ +package com.dotmarketing.portlets.workflows.actionlet.event; + +import com.dotmarketing.portlets.contentlet.model.Contentlet; + +import java.io.Serializable; + +public class CopyActionletEvent implements Serializable { + + private final Contentlet originalContentlet; + private final Contentlet copyContentlet; + + public CopyActionletEvent(Contentlet originalContentlet, Contentlet copyContentlet) { + this.originalContentlet = originalContentlet; + this.copyContentlet = copyContentlet; + } + + public Contentlet getOriginalContentlet() { + return originalContentlet; + } + + public Contentlet getCopyContentlet() { + return copyContentlet; + } +} diff --git a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowAPIImpl.java b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowAPIImpl.java index 858bff86793d..82f96c1bae95 100644 --- a/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowAPIImpl.java +++ b/dotCMS/src/main/java/com/dotmarketing/portlets/workflows/business/WorkflowAPIImpl.java @@ -68,7 +68,8 @@ public WorkflowAPIImpl() { PushNowActionlet.class, TranslationActionlet.class, SaveContentActionlet.class, - SaveContentAsDraftActionlet.class + SaveContentAsDraftActionlet.class, + CopyActionlet.class })); refreshWorkFlowActionletMap();