11

Scenario: (In SDL Tridion 2011 SP1 HR1)

We have a storage extension which indexes the Component Presentation in SOLR, now If due to some reason this indexing is failed, we want to rollback the publishing and emit a Failure status to CME GUI with a Custom message.

What we have achieved so far and what is the issue:

We are able to rollback and emit the failure to GUI successfully. We sent the custom message as well but it get displayed twice on the CME GUI along with some default message from Tridion.

What we need:

We want to show only non-redundant custom message that we sent through storage extension. Is it possible to control this behaviour and is it possible to show a specific custom message on rollback and failure through storage extension. Did any one in the group come across any out of the box or tailor made solution.

Per Bart's suggestion Below is the code I am using for sending back the custom messages in the Storage Extension written for Dynamic Component Presentation:

public void create(ComponentPresentation itemToCreate, ComponentPresentationTypeEnum componentPresentationType)
    throws StorageException
    {

      try
      {
           .. Code for Indexing the Data in SOLR and capturing any error..

           if(<Indexing is successful>) {do nothing}
           else
           {
              throw new StorageException(<Custom Error Message>);
           }

      } 

      catch(Exception ex)
      {
        throw new StorageException(<Custom Error Message>); 
      }  

    }
11
  • I might be wrong, but I think that OOTB this is not possible - your custom error messages will not be passed back to the CM. I will double check this tomorrow.
    – Nuno Linhares
    Apr 16, 2013 at 19:58
  • Thanks Nuno; we are able to pass back the custom error messages back to CM via Storage Extension, the issue is that message is displayed multiple times. Apr 17, 2013 at 2:24
  • @PankajGaur perhaps you can share some more detail (like code) on what is, and how you are sending the messages back? It would make sense to me that that is responsible for the duplication somehow, and with more information we can hopefully come to an answer for this question. May 15, 2013 at 11:27
  • @BartKoopman - I have already added some indicative code in this regard. Let me know if any specific code I need to add May 15, 2013 at 11:30
  • @PankajGaur can you differentiate which of the error messages are being returned, is it the one in your else or the catch clause? May 15, 2013 at 11:38

2 Answers 2

4

Your first thrown exception will be caught in your catch(), as you are catching all Exceptions. You could be more specific in the kinds of exceptions you are catching - or at least make an exception for StorageExceptions, like this:

public void create(ComponentPresentation itemToCreate, ComponentPresentationTypeEnum componentPresentationType)
    throws StorageException
    {

      try
      {
           .. Code for Indexing the Data in SOLR and capturing any error..

           if(<Indexing is successful>) {do nothing}
           else
           {
              throw new StorageException(<Custom Error Message>);
           }

      } 
      catch(StorageException ex)
      {
        throw ex;
      }  
      catch(Exception ex)
      {
        throw new StorageException(<Custom Error Message>); 
      }  

    }
1
  • This makes sense to me...I will try this and see if this is the issue. +1 for the valuable suggestion though. Jan 24, 2014 at 8:08
-1

Assuming that you're showing messages via the Event System. If you subscribed to an event that encompasses two or more child events, for example PublishEventArgs is a parent for PublishOrUnPublishEventArgs and SetPublishStateEventArgs, then your logic would be triggered in instances of both of the child events. This would explain why you see the error message twice. You need to narrow down and subscribe to the most specific event so that it is the only one you show a message on.

If you share your code/which event(s) you've subscribed to, to fire the message, we can help further.

1
  • Thanks for your reply Nickoli, but I am not using Event System at all but using Storage Extension. I might have an idea about why they are coming twice even if I try to override directly at the storage layer, but I am looking for a solution to overcome this. Apr 16, 2013 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.