tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/18781-develop-a-debug-triggerCascade CMS: Discussion 2015-08-11T19:12:14Ztag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-15T19:38:09Z2015-07-15T19:38:09ZDevelop a Publish Trigger <div><p>anybody ??</p></div>ediegotag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-15T20:29:29Z2015-07-15T20:30:23ZDevelop a Publish Trigger <div><p>Hi Emil,</p>
<p>Our apologies for the delayed response to your discussion, it
looks like it was set to private which would be why no one outside
of Hannon Hill saw your questions.</p>
<blockquote>
<p>Is there any documentation on the PublishTrigger SDK and more in
depth examples?</p>
</blockquote>
<p>Beyond that page, there isn't much else in terms of
documentation. As for examples, there is the simple example at the
bottom of <a href="http://www.hannonhill.com/kb/Publish-Triggers/">the page you
linked</a>, or you can also access it on <a href="https://github.com/hannonhill/Cascade-Server-Publish-Trigger-SDK">the
Publish Trigger SDK Github project</a>. I also have a couple of
triggers that I published as gists on Github:</p>
<ul>
<li><a href="https://gist.github.com/rgriffith/28ca51a9f24d6d285d21">https://gist.github.com/rgriffith/28ca51a9f24d6d285d21</a>
- Docx Publish Trigger that ships with Cascade</li>
<li><a href="https://gist.github.com/rgriffith/7ad8e1639dc77e4dde7f">https://gist.github.com/rgriffith/7ad8e1639dc77e4dde7f</a>
- Publish Trigger that calls an external script with the publishing
asset's information</li>
</ul>
<blockquote>
<p>The code uses system.out to output debug information, but where
does that output go?</p>
</blockquote>
<p>If I recall, this type of logging is displayed within
<code>tomcat/logs/catalina.out</code>.</p>
<blockquote>
<p>I would like to integrate my plugin logging into the Logging
functionality that already exists in cascade server. Is there any
documentation or examples that shows how to do that?</p>
</blockquote>
<p>There is actually an <a href="https://gist.github.com/rgriffith/28ca51a9f24d6d285d21#file-docxpublishtrigger-java-L65">
example of this within the Docx Publish Trigger</a> I linked
above.</p>
<p>Basically, you add the following above your constructor:</p>
<pre>
<code>private static final Logger LOG = Logger.getLogger(DocxPublishTrigger.class);</code>
</pre>
<p>And add logging statements like <a href="https://gist.github.com/rgriffith/28ca51a9f24d6d285d21#file-docxpublishtrigger-java-L117">
this one</a>.</p>
<p>Then, <a href="http://www.hannonhill.com/kb/Logging/">enable
debug logging</a> (or whatever level you choose) for your Publish
Trigger class by passing in the full path to your class (eg
<code>com.cms.publish.client.DocxPublishTrigger</code>).</p>
<p>Note: replace <code>DocxPublishTrigger</code> with the class
name of your Publish Trigger.</p>
<p>The logging will be output to
<code>tomcat/logs/cascade.log</code>.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-16T12:04:22Z2015-07-16T12:04:22ZDevelop a Publish Trigger <div><p>Awesome, thanks. I'll take a look at those.</p></div>ediegotag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-16T12:33:36Z2015-07-16T12:33:36ZDevelop a Publish Trigger <div><p>Not a problem at all, Emil. I'm going to go ahead and close this
discussion, but please feel free to comment or reply to re-open if
you have any additional questions.</p>
<p>Have a great day!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-20T11:40:05Z2015-07-20T11:40:05ZDevelop a Publish Trigger <div><p>I got really far with this over the weekend. I implemented the
logging and have the css and js file contents being compressed in
the publish trigger. Just have a few questions about how to publish
that content. Thanks again for all your help.</p>
<ol>
<li>
<p>Is there any mechanism built into the publish trigger API that
allows me to override the file contents that gets published to the
Destination? Or does the CMS just publish the content normally and
then calls the publish trigger after that step?</p>
</li>
<li>
<p>If that's the case then do I have to manually FTP the contents
of the new file to the Destination?</p>
</li>
<li>
<p>To cover all the transport types I would need to implement a
method to write the compressed file contents to the local
filesystem, the database, and a FTP/SFTP server? The file system
and FTP/SFTP seem pretty straight forward, but I'm not sure how to
implement the database transport. Are there any examples of this
?</p>
</li>
</ol></div>ediegotag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-22T11:59:20Z2015-07-22T11:59:20ZDevelop a Publish Trigger <div><p>bump</p></div>ediegotag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-23T12:13:08Z2015-07-23T12:13:08ZDevelop a Publish Trigger <div><p>Hi Emil,</p>
<p>After some digging, I was able to locate <a href="http://help.hannonhill.com/discussions/how-do-i/10607-minify-cssjs-during-publish">
this related discussion</a> I had with another client, perhaps the
thread might prove to be useful.</p>
<blockquote>
<p>Is there any mechanism built into the publish trigger API that
allows me to override the file contents that gets published to the
Destination? Or does the CMS just publish the content normally and
then calls the publish trigger after that step?</p>
</blockquote>
<p>For each asset that gets published during a publish job your
publish trigger will be invoked for each available Output and
Destination, so this would be after the actual publish. Each time
the trigger is invoked, you will have access to the following
information:</p>
<ul>
<li>entityType</li>
<li>entityId</li>
<li>entityPath</li>
<li>targetId (if in Global)</li>
<li>targetPath (if in Global)</li>
<li>destination (same as destinationId below)</li>
<li>transportId</li>
<li>destinationId</li>
<li>destinationName</li>
<li>pageConfigurationId</li>
<li>unpublish</li>
</ul>
<p>For asset content, you should be able to perform additional read
operations using the information provided to you. If you are
dealing with Files, you should be able to read the File asset to
obtain it's content, pass it though some sort of compression and
then use the Transport/Destination information to send the file
back out, similar to what the <a href="https://gist.github.com/rgriffith/28ca51a9f24d6d285d21">.docx
trigger</a> does. Pages would be a little more difficult since you
would just get structured data and not the rendered content.</p>
<blockquote>
<p>If that's the case then do I have to manually FTP the contents
of the new file to the Destination?</p>
</blockquote>
<p>Correct, you would use the Transport/Destination information
provided to the publish trigger. See above.</p>
<blockquote>
<p>To cover all the transport types I would need to implement a
method to write the compressed file contents to the local
filesystem, the database, and a FTP/SFTP server? The file system
and FTP/SFTP seem pretty straight forward, but I'm not sure how to
implement the database transport. Are there any examples of this
?</p>
</blockquote>
<p>Correct, you would need to implement each type of Transport
depending on your use case. For Database Transports, obtaining the
connection information would be similar to FTP/SFTP; however,
instead of opening an FTP connection you are opening a database
connection. If you are dealing with Files, database publishing does
only publishes page content (DEFAULT region) and not file
content.</p>
<p>That being said, if you are looking to minify specific files,
you could set up a page that has a file chooser and a single
DEFAULT region with a Velocity Format that reads the file's content
using the Locator Tool and strips all line breaks.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-23T12:33:14Z2015-07-23T12:33:14ZDevelop a Publish Trigger <div><p>Thanks. I already have the publish trigger reading the contents
of a "File" and compressing them. js and css files. I was just
wondering what the best way to write that content out to the
destination.</p>
<p>Since your software supports mysql, oracle and MS SQL then I
would have to write classes for all those platforms. Not something
I am particularly looking forward. I was just hoping there was a
mechanism built into the PublishTrigger API that would allow me to
write the modified content, since that functionality is already
implemented in the CMS.</p>
<p>For phase 1 of my Publish Trigger I will just support FTP
destinations and filesystem and only worry about database
destinations if there is some over whelming need for that.</p>
<p>Thanks a lot for your help and guidance on this.</p></div>ediegotag:help-archives.hannonhill.com,2010-02-09:Comment/373611582015-07-23T13:05:04Z2015-07-23T13:05:04ZDevelop a Publish Trigger <div><p>Hi Emil,</p>
<blockquote>
<p>Since your software supports mysql, oracle and MS SQL then I
would have to write classes for all those platforms. Not something
I am particularly looking forward. I was just hoping there was a
mechanism built into the PublishTrigger API that would allow me to
write the modified content, since that functionality is already
implemented in the CMS.</p>
</blockquote>
<p>As I mentioned, Database Transports will not publish file
content, only system and metadata information about the file. With
that said, it sounds as though you won't need to add additional
code for these types of Transports.</p>
<p>As always, please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffith