tag:help-archives.hannonhill.com,2010-02-09:/discussions/web-services/1516-delete-and-unpublishCascade CMS: Discussion 2018-10-18T20:37:34Ztag:help-archives.hannonhill.com,2010-02-09:Comment/370429102015-06-04T19:06:20Z2015-06-05T14:56:25ZDelete and Unpublish<div><p>Hi,</p>
<p>I would say that the best option is to use triggers. But if you
have to use web services, then this is my suggestion:</p>
<ol>
<li>Assuming that you have a way to identify the assets you want to
delete, store the Id's in an array<br></li>
<li>Schedule a cron job to unpublished the assets, using a web
service script<br>
3, Schedule another cron job, maybe an hour later, to delete the
assets, using another script</li>
</ol>
<p>These two scripts can be scheduled to run, for example, every
day.</p>
<p>Wing</p></div>Wing Ming Chantag:help-archives.hannonhill.com,2010-02-09:Comment/370429102015-06-05T20:04:54Z2015-06-05T20:04:54ZDelete and Unpublish<div><p>Hi,</p>
<p>I will need to verify this, but you might be able to call the
<code>delete</code> operation and pass in a workflow configuration
that points to an automated workflow which calls the
<code>deleteAndUnpublish</code> trigger.</p>
<p>I will follow up once I gather some additional information.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/370429102015-06-22T18:26:48Z2015-06-22T18:50:03ZDelete and Unpublish<div><p>Hi,</p>
<p>This is what I did to unpublish and delete a page at the same
time, using my library. First, I need to create a workflow
definition using the <code>UnpublishAndDelete</code> trigger:</p>
<pre>
$site_name = "_common";
$wd_name = "Unpublish and Delete";
$parent = $cascade->getAsset(
a\WorkflowDefinitionContainer::TYPE, 'fd2770ba8b7f08560159f3f03223b508' );
$xml = "<system-workflow-definition name='$wf_name' initial-step='initialize'>
<triggers>
<trigger name='AssignStepIfUser' class='com.cms.workflow.function.AssignStepIfUser'/>
<trigger name='AssignToGroupOwningAsset' class='com.cms.workflow.function.AssignToGroupOwningAsset'/>
<trigger name='AssignToSpecifiedGroup' class='com.cms.workflow.function.AssignToSpecifiedGroup'/>
<trigger name='AssignToWorkflowOwner' class='com.cms.workflow.function.AssignToWorkflowOwner'/>
<trigger name='CopyFolder' class='com.cms.workflow.function.CopyFolder'/>
<trigger name='com.cms.workflow.function.CreateNewWorkflowTrigger' class='com.cms.workflow.function.CreateNewWorkflowTrigger'/>
<trigger name='Delete' class='com.cms.workflow.function.Delete'/>
<trigger name='UnpublishAndDelete' class='com.cms.workflow.function.DeleteAndUnpublish'/>
<trigger name='DeleteParentFolder' class='com.cms.workflow.function.DeleteParentFolderTrigger'/>
<trigger name='Email' class='com.cms.workflow.function.EmailProvider'/>
<trigger name='Merge' class='com.cms.workflow.function.Merge'/>
<trigger name='PreserveCurrentUser' class='com.cms.workflow.function.PreserveCurrentUser'/>
<trigger name='PublishContainingPublishSet' class='com.cms.workflow.function.PublishContainingPublishSetTrigger'/>
<trigger name='PublishParentFolder' class='com.cms.workflow.function.PublishParentFolderTrigger'/>
<trigger name='PublishSet' class='com.cms.workflow.function.PublishSetTrigger'/>
<trigger name='Publish' class='com.cms.workflow.function.Publisher'/>
<trigger name='Version' class='com.cms.workflow.function.Version'/>
<trigger name='CreateNewWorkflow' class='com.cms.workflow.function.CreateNewWorkflowsTrigger'/>
</triggers>
<steps>
<step type='system' identifier='initialize' label='Initialization'>
<actions>
<action identifier='publish' label='Publish' move='forward' >
<trigger name='UnpublishAndDelete' />
</action>
</actions>
</step>
<step type='system' identifier='finished' label='Finished'/>
</steps>
<non-ordered-steps/>
</system-workflow-definition>";
// create workflow definition
$wd =
$cascade->createWorkflowDefinition(
$parent,
$wd_name,
a\WorkflowDefinition::NAMING_BEHAVIOR_AUTO, // naming behavior
$xml
)->
setCopy( false )->
setCreate( false )->
setDelete( true )->
setEdit( false )->
edit();
</pre>
<p>Secondly, with the workflow definition in place, I just need to
edit the page in the following way:<br></p>
<pre>
$page = $cascade->getAsset(
a\Page::TYPE, 'e7c936d78b7f085600b2e0be6a34e4ab' );
$wd = $cascade->getAsset(
a\WorkflowDefinition::TYPE, $wd_name, $site_name );
$page->edit( NULL, $wd, $wd_name, "To be unpublished and deleted", false );
</pre>
The <code>edit</code> method is called here to associate a page
with a workflow. This code works because the <code>edit</code>
method defined in <code>a\Page</code> takes care of the workflow
configuration when <code>$wd</code> is passed in. Workflow step
configurations are bypassed though. The last argument,
<code>false</code>, is passed in to skip processing of the
structured data of the page, because right after the
<code>edit</code> method is called, the page will be deleted, and
there is no structured data to process. Without the
<code>false</code> value, warnings will be issued.
<p>Wing</p></div>Wing Ming Chantag:help-archives.hannonhill.com,2010-02-09:Comment/370429102015-06-22T21:41:23Z2015-06-22T21:41:23ZDelete and Unpublish<div><p>Thank you Wing! Using the workflow you provided above worked for
me.</p></div>ces55739