Creating files on publish

jeberwei's Avatar


13 Jul, 2010 09:07 PM


I want to know if Cascade has the ability to create and publish a file via a trigger.

Basically, I have an asset created. When I go to publish a page on my site, I want a different page created from that asset and published to the site. The file itself should not sit in cascade only published to the server.

This is for a navigation include file. Each time a user publishes a page from their site, the server would create a new page via an asset, publish it, then delete from cascade.

Is this possible at all?

  1. 1 Posted by Syl on 14 Jul, 2010 09:03 PM

    Syl's Avatar

    This sounds possible to do by creating a publish trigger ( A Publish Trigger is custom code written in Java that executes on publish.

  2. 2 Posted by jeberwei on 14 Jul, 2010 11:58 PM

    jeberwei's Avatar

    Hi There,

    I downloaded the api and sample.

    I see that there is one sample jar file, but I honestly am not sure what it does (other than see if a file, or page is published)

    Is there any external documentation for the cascade api specifically? (like:

    I think the cascade.api is where I need to find the info to create, publish, and delete the asset.

    Just want to figure out where to get started.

  3. 3 Posted by jeberwei on 15 Jul, 2010 05:36 PM

    jeberwei's Avatar

    Specifically com.hannonhill.cascade.api.operation (and classes within)
    The others I open in Eclipse seem to work. These I get a:
    "Source not found" message The source attachment does not contain the source for the Create.class

  4. 4 Posted by Syl on 15 Jul, 2010 06:52 PM

    Syl's Avatar

    I've attached the javadocs for com.hannonhill.cascade.api.operation package. Hopefully this helps (and hopefully our comments aren't out of date). We're going to look into generating the javadocs for the entire API to post online in the future.

  5. Tim closed this discussion on 20 Jul, 2010 03:48 PM.

  6. jeberwei re-opened this discussion on 21 Jul, 2010 05:45 PM

  7. 5 Posted by jeberwei on 21 Jul, 2010 05:45 PM

    jeberwei's Avatar

    Hello again,

    This is helpful thanks.
    However, do you by chance have any samples of triggers that might use the copy command? I'm trying to figure out how to get the name of the asset I want to copy, and the name of the folder I want to copy into.


  8. 6 Posted by Syl on 27 Jul, 2010 10:04 PM

    Syl's Avatar

    Unfortunately, I can't find any examples we around here, but I threw this method together which might help you get started:

    private String copyAsset(Identifier toCopy, Identifier destinationContainer) throws Exception
        Copy copy = new Copy();
        CopyOperationResult result = (CopyOperationResult) copy.perform();
        return result.getCopiedAssetId();       

    Here are a couple other things you might need (I found them in some example Publish Trigger classes):

    private BaseAsset readAsset(Identifier identifier) throws Exception
        Read read = new Read();
        ReadOperationResult result = (ReadOperationResult) read.perform();
        return result.getAsset();
    private class IdentifierImpl implements Identifier
        private final String id;
        private final EntityType type;
        public IdentifierImpl(String id, EntityType type)
   = id;
            this.type = type;
        public String getId()
            return id;
        public EntityType getType()
            return type;

    Basically, in your Publish Trigger, you can use the readAsset() method to pull out an asset by id. Here's a simple example of that with a page:

    IdentifierImpl id = new IdentifierImpl(information.getEntityId(), EntityTypes.TYPE_PAGE);
    Page page = (Page) readAsset(id);
    String name = page.getName();

    (In this example, information is PublishTriggerInformation).

    You can use that copyAsset() method to copy an asset to the destination container. It returns the id of the newly created asset. So if you want to get the name of it, just get that new id and call the readAsset() method.

    I hope this is enough to get you started. I wish there was an example already written that I could point you to.

  9. Tim closed this discussion on 25 Aug, 2010 03:11 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac