You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Florent André <fl...@4sengines.com> on 2009/05/10 22:14:45 UTC

How to Publish document in Java ?

Hi,

I create a lenyaDoc in my code and commit the session : my document is in
the authoring area.

After that I want to publish my lenyaDoc. I try many piece of code, but
nothing work...

Can you help me please ?


org.apache.cocoon.environment.Session cocoonSession = request.getSession();
Identity identity = (Identity)
cocoonSession.getAttribute(Identity.class.getName());
Session session = RepositoryUtil.createSession(this.manager, identity,
true);


//Session session = RepositoryUtil.createSession(this.manager, null);
//Session session = lenyaDoc.getRepositoryNode().getSession();
  

WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
"submit");
WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
"publish");
session.commit();

Have good day


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Florent André <fl...@4sengines.com>.
On Wed, 13 May 2009 18:24:14 +0200, Andreas Hartmann <an...@apache.org>
wrote:
> Florent André schrieb:
>> On Wed, 13 May 2009 17:51:41 +0200, Andreas Hartmann
<an...@apache.org>
>> wrote:
>> 
>>> do you think you could implement a unit test for this issue? This would

>>> make it much easier to find the cause of the problem.
>> 
>> Heuuu, yes I will try. I have never do that before so preparing you to
>> have
>> some questions ! :) 
> 
> Spending time on this won't be in vain, unit tests are very useful :)

Yes, I'm totally agree with you. I like the agile idea "first write test
and after code"... but I don't apply that until now :( 
Unfortunatly, I take a look to unit tests... and I really can't spend time
the require learning time on this now.

In order to "respect" my past deadlines :) I will set up a cross over
technique.

But be sure that I will try to solve this problem and that you will see me
on this subject !

Thanks for your help
Bye


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Andreas Hartmann <an...@apache.org>.
Florent André schrieb:
> On Wed, 13 May 2009 17:51:41 +0200, Andreas Hartmann <an...@apache.org>
> wrote:
>> Hi André,
>>
>> Florent André schrieb:
>>> Hi,
>>>
>>> I try to add this : 
>>> lenyaDoc.getRepositoryNode().getSession().commit(); (lenyaDoc is a
>>> o.a.l.cms.publication.Document object)
>>>
>>> between invoker A and invoker B.
>>>
>>> I have hope that it update the session... but I have the same error.
>> do you think you could implement a unit test for this issue? This would 
>> make it much easier to find the cause of the problem.
> 
> 
> Heuuu, yes I will try. I have never do that before so preparing you to have
> some questions ! :) 

Spending time on this won't be in vain, unit tests are very useful :)

> Do you think that I'm facing to a bug ?

I'm not sure yet, but it is possible. At a first glance your code looks 
OK. But in order to analyze it, a unit test would be very useful.

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Florent André <fl...@4sengines.com>.
On Wed, 13 May 2009 17:51:41 +0200, Andreas Hartmann <an...@apache.org>
wrote:
> Hi André,
> 
> Florent André schrieb:
>> Hi,
>> 
>> I try to add this : 
>> lenyaDoc.getRepositoryNode().getSession().commit(); (lenyaDoc is a
>> o.a.l.cms.publication.Document object)
>> 
>> between invoker A and invoker B.
>> 
>> I have hope that it update the session... but I have the same error.
> 
> do you think you could implement a unit test for this issue? This would 
> make it much easier to find the cause of the problem.


Heuuu, yes I will try. I have never do that before so preparing you to have
some questions ! :) 

Do you think that I'm facing to a bug ?

Regards

> 
> Here's some information:
> http://lenya.apache.org/docu20/tutorials/tests.html
> 
> -- Andreas
> 
> 
>> 
>> TIA
>> 
>> Have a good day
>> 
>> On Tue, 12 May 2009 19:16:53 +0200, Florent André
>> <fl...@4sengines.com> wrote:
>>> On Tue, 12 May 2009 15:08:03 +0200, Andreas Hartmann
>>> <an...@apache.org>
>>> wrote:
>>>> [[...]]
>>>>
>>>> My guess is that:
>>>>
>>>> * the second usecase invoker (let's call it B) initializes the session

>>>> SB before the first usecase invoker is called
>>>>
>>>> * the changes which usecase invoker A makes to session SA are not 
>>>> visible in session SB
>>>>
>>>> * therefore the document in SB is still in authoring and the workflow 
>>>> transition can't fire
>>>>
>>>> Is this possible? Would you mind sending the complete code snippet?
>>>> TIA!
>>> This seems to me a very good possible explanation.
>>> But with invoker I don't use a session explicitly (maybe the problem
>> cause
>>> ?). I set-up a session for the creation of the document and commit this
>>> session at the end of doc creation.
>>>
>>> Here I send just send you the function that contain invoker. I can send
>> the
>>> full code of my lenyadoctransformer if needed (I hope to publish it one
>> day
>>> :) 
>>>
>>> This piece of code is the actual result of many different test (the all
>>> copy-past with 2 is the last)... so be gracefull please :) but i'm
>>> really
>>> open to all remark
>>>
>>> Here we go : 
>>> private void applyWorkflowState()
>>>         throws ProcessingException, SAXException{
>>>
>>>  UsecaseInvoker invoker = null;
>>>             try {
>>>                 invoker = (UsecaseInvoker)
>>> this.manager.lookup(UsecaseInvoker.ROLE);
>>>                 Map params = new HashMap();
>>>                 //params.put(..., ...);
>>>                 //invoker.invoke(getSourceUrl(), "publish", params);
>>>                 //reportResult("","PROBLEM","USECASE
>>>
PROBLEM",lenyaDoc.getCanonicalDocumentURL(),lenyaDoc.getCanonicalWebappU\
>>> RL(),"");
>>>                 invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
>>> "workflow.submit", params);
>>>                 //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
>>> "workflow.publish", params);
>>>
>>>                 if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
>>>                     /*A REMETTRE*/
>>>                       List messages = invoker.getErrorMessages();
>>>                     for (Iterator i = messages.iterator();
i.hasNext();)
>> {
>>>                         UsecaseMessage message = (UsecaseMessage)
>> i.next();
>>>                         //addErrorMessage(message.getMessage(),
>>> message.getParameters());
>>>                         reportResult("","PROBLEM","USECASE
>>>
>>
PROBLEM",message.getMessage(),Arrays.toString(message.getParameters()),"");
>>>                     }
>>>                 }
>>>             }
>>>             catch( ServiceException se){
>>>                
>>> reportResult("","PROBLEM","ServiceException",se.getMessage(),"","");
>>>             }
>>>             catch (UsecaseException ue){
>>>                
>>> reportResult("","PROBLEM","UsecaseException",ue.getMessage(),"","");
>>>             }
>>>             finally {
>>>                 if (invoker != null) {
>>>                     this.manager.release(invoker);
>>>                 }
>>>             }
>>>
>>>             UsecaseInvoker invoker2 = null;
>>>             try {
>>>  UsecaseInvoker invoker2 = null;
>>>             try {
>>>                 invoker2 = (UsecaseInvoker)
>>> this.manager.lookup(UsecaseInvoker.ROLE);
>>>                 Map params2 = new HashMap();
>>>                 //params.put(..., ...);
>>>                 //invoker.invoke(getSourceUrl(), "publish", params);
>>>                 //reportResult("","PROBLEM","USECASE
>>>
>>
PROBLEM",lenyaDoc.getCanonicalDocumentURL(),lenyaDoc.getCanonicalWebappURL(),"");
>>>                 //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
>>> "workflow.submit", params);
>>>                 invoker2.invoke(lenyaDoc.getCanonicalWebappURL(),
>>> "workflow.publish", params2);
>>>
>>>                 if (invoker2.getResult() != UsecaseInvoker.SUCCESS) {
>>>                     //A REMETTRE
>>>                       List messages2 = invoker2.getErrorMessages();
>>>                     for (Iterator i2 = messages2.iterator();
>> i2.hasNext();)
>>> {
>>>                         UsecaseMessage message2 = (UsecaseMessage)
>>> i2.next();
>>>                         //addErrorMessage(message2.getMessage(),
>>> message2.getParameters());
>>>                         reportResult("","PROBLEM","USECASE
>>>
>>
PROBLEM22",message2.getMessage(),Arrays.toString(message2.getParameters()),"");
>>>                     }
>>>                 }
>>>             }
>>>             catch( ServiceException se){
>>>                
>>> reportResult("","PROBLEM2","ServiceException",se.getMessage(),"","");
>>>             }
>>>             catch (UsecaseException ue){
>>>                
>>> reportResult("","PROBLEM2","UsecaseException",ue.getMessage(),"","");
>>>             }
>>>             finally {
>>>                 if (invoker2 != null) {
>>>                     this.manager.release(invoker2);
>>>                 }
>>>                 }
>>> }
>>>
>>> Thanks for your help
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>>> For additional commands, e-mail: user-help@lenya.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Andreas Hartmann <an...@apache.org>.
Hi André,

Florent André schrieb:
> Hi,
> 
> I try to add this : 
> lenyaDoc.getRepositoryNode().getSession().commit(); (lenyaDoc is a
> o.a.l.cms.publication.Document object)
> 
> between invoker A and invoker B.
> 
> I have hope that it update the session... but I have the same error.

do you think you could implement a unit test for this issue? This would 
make it much easier to find the cause of the problem.

Here's some information: http://lenya.apache.org/docu20/tutorials/tests.html

-- Andreas


> 
> TIA
> 
> Have a good day
> 
> On Tue, 12 May 2009 19:16:53 +0200, Florent André
> <fl...@4sengines.com> wrote:
>> On Tue, 12 May 2009 15:08:03 +0200, Andreas Hartmann <an...@apache.org>
>> wrote:
>>> [[...]]
>>>
>>> My guess is that:
>>>
>>> * the second usecase invoker (let's call it B) initializes the session 
>>> SB before the first usecase invoker is called
>>>
>>> * the changes which usecase invoker A makes to session SA are not 
>>> visible in session SB
>>>
>>> * therefore the document in SB is still in authoring and the workflow 
>>> transition can't fire
>>>
>>> Is this possible? Would you mind sending the complete code snippet? TIA!
>> This seems to me a very good possible explanation.
>> But with invoker I don't use a session explicitly (maybe the problem
> cause
>> ?). I set-up a session for the creation of the document and commit this
>> session at the end of doc creation.
>>
>> Here I send just send you the function that contain invoker. I can send
> the
>> full code of my lenyadoctransformer if needed (I hope to publish it one
> day
>> :) 
>>
>> This piece of code is the actual result of many different test (the all
>> copy-past with 2 is the last)... so be gracefull please :) but i'm really
>> open to all remark
>>
>> Here we go : 
>> private void applyWorkflowState()
>>         throws ProcessingException, SAXException{
>>
>>  UsecaseInvoker invoker = null;
>>             try {
>>                 invoker = (UsecaseInvoker)
>> this.manager.lookup(UsecaseInvoker.ROLE);
>>                 Map params = new HashMap();
>>                 //params.put(..., ...);
>>                 //invoker.invoke(getSourceUrl(), "publish", params);
>>                 //reportResult("","PROBLEM","USECASE
>> PROBLEM",lenyaDoc.getCanonicalDocumentURL(),lenyaDoc.getCanonicalWebappU\
>> RL(),"");
>>                 invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
>> "workflow.submit", params);
>>                 //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
>> "workflow.publish", params);
>>
>>                 if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
>>                     /*A REMETTRE*/
>>                       List messages = invoker.getErrorMessages();
>>                     for (Iterator i = messages.iterator(); i.hasNext();)
> {
>>                         UsecaseMessage message = (UsecaseMessage)
> i.next();
>>                         //addErrorMessage(message.getMessage(),
>> message.getParameters());
>>                         reportResult("","PROBLEM","USECASE
>>
> PROBLEM",message.getMessage(),Arrays.toString(message.getParameters()),"");
>>                     }
>>                 }
>>             }
>>             catch( ServiceException se){
>>                
>> reportResult("","PROBLEM","ServiceException",se.getMessage(),"","");
>>             }
>>             catch (UsecaseException ue){
>>                
>> reportResult("","PROBLEM","UsecaseException",ue.getMessage(),"","");
>>             }
>>             finally {
>>                 if (invoker != null) {
>>                     this.manager.release(invoker);
>>                 }
>>             }
>>
>>             UsecaseInvoker invoker2 = null;
>>             try {
>>  UsecaseInvoker invoker2 = null;
>>             try {
>>                 invoker2 = (UsecaseInvoker)
>> this.manager.lookup(UsecaseInvoker.ROLE);
>>                 Map params2 = new HashMap();
>>                 //params.put(..., ...);
>>                 //invoker.invoke(getSourceUrl(), "publish", params);
>>                 //reportResult("","PROBLEM","USECASE
>>
> PROBLEM",lenyaDoc.getCanonicalDocumentURL(),lenyaDoc.getCanonicalWebappURL(),"");
>>                 //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
>> "workflow.submit", params);
>>                 invoker2.invoke(lenyaDoc.getCanonicalWebappURL(),
>> "workflow.publish", params2);
>>
>>                 if (invoker2.getResult() != UsecaseInvoker.SUCCESS) {
>>                     //A REMETTRE
>>                       List messages2 = invoker2.getErrorMessages();
>>                     for (Iterator i2 = messages2.iterator();
> i2.hasNext();)
>> {
>>                         UsecaseMessage message2 = (UsecaseMessage)
>> i2.next();
>>                         //addErrorMessage(message2.getMessage(),
>> message2.getParameters());
>>                         reportResult("","PROBLEM","USECASE
>>
> PROBLEM22",message2.getMessage(),Arrays.toString(message2.getParameters()),"");
>>                     }
>>                 }
>>             }
>>             catch( ServiceException se){
>>                
>> reportResult("","PROBLEM2","ServiceException",se.getMessage(),"","");
>>             }
>>             catch (UsecaseException ue){
>>                
>> reportResult("","PROBLEM2","UsecaseException",ue.getMessage(),"","");
>>             }
>>             finally {
>>                 if (invoker2 != null) {
>>                     this.manager.release(invoker2);
>>                 }
>>                 }
>> }
>>
>> Thanks for your help
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>> For additional commands, e-mail: user-help@lenya.apache.org


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Florent André <fl...@4sengines.com>.
Hi,

I try to add this : 
lenyaDoc.getRepositoryNode().getSession().commit(); (lenyaDoc is a
o.a.l.cms.publication.Document object)

between invoker A and invoker B.

I have hope that it update the session... but I have the same error.

TIA

Have a good day

On Tue, 12 May 2009 19:16:53 +0200, Florent André
<fl...@4sengines.com> wrote:
> On Tue, 12 May 2009 15:08:03 +0200, Andreas Hartmann <an...@apache.org>
> wrote:
>> [[...]]
>> 
>> My guess is that:
>> 
>> * the second usecase invoker (let's call it B) initializes the session 
>> SB before the first usecase invoker is called
>> 
>> * the changes which usecase invoker A makes to session SA are not 
>> visible in session SB
>> 
>> * therefore the document in SB is still in authoring and the workflow 
>> transition can't fire
>> 
>> Is this possible? Would you mind sending the complete code snippet? TIA!
> 
> This seems to me a very good possible explanation.
> But with invoker I don't use a session explicitly (maybe the problem
cause
> ?). I set-up a session for the creation of the document and commit this
> session at the end of doc creation.
> 
> Here I send just send you the function that contain invoker. I can send
the
> full code of my lenyadoctransformer if needed (I hope to publish it one
day
> :) 
> 
> This piece of code is the actual result of many different test (the all
> copy-past with 2 is the last)... so be gracefull please :) but i'm really
> open to all remark
> 
> Here we go : 
> private void applyWorkflowState()
>         throws ProcessingException, SAXException{
> 
>  UsecaseInvoker invoker = null;
>             try {
>                 invoker = (UsecaseInvoker)
> this.manager.lookup(UsecaseInvoker.ROLE);
>                 Map params = new HashMap();
>                 //params.put(..., ...);
>                 //invoker.invoke(getSourceUrl(), "publish", params);
>                 //reportResult("","PROBLEM","USECASE
> PROBLEM",lenyaDoc.getCanonicalDocumentURL(),lenyaDoc.getCanonicalWebappU\
> RL(),"");
>                 invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
> "workflow.submit", params);
>                 //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
> "workflow.publish", params);
> 
>                 if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
>                     /*A REMETTRE*/
>                       List messages = invoker.getErrorMessages();
>                     for (Iterator i = messages.iterator(); i.hasNext();)
{
>                         UsecaseMessage message = (UsecaseMessage)
i.next();
>                         //addErrorMessage(message.getMessage(),
> message.getParameters());
>                         reportResult("","PROBLEM","USECASE
>
PROBLEM",message.getMessage(),Arrays.toString(message.getParameters()),"");
>                     }
>                 }
>             }
>             catch( ServiceException se){
>                
> reportResult("","PROBLEM","ServiceException",se.getMessage(),"","");
>             }
>             catch (UsecaseException ue){
>                
> reportResult("","PROBLEM","UsecaseException",ue.getMessage(),"","");
>             }
>             finally {
>                 if (invoker != null) {
>                     this.manager.release(invoker);
>                 }
>             }
> 
>             UsecaseInvoker invoker2 = null;
>             try {
>  UsecaseInvoker invoker2 = null;
>             try {
>                 invoker2 = (UsecaseInvoker)
> this.manager.lookup(UsecaseInvoker.ROLE);
>                 Map params2 = new HashMap();
>                 //params.put(..., ...);
>                 //invoker.invoke(getSourceUrl(), "publish", params);
>                 //reportResult("","PROBLEM","USECASE
>
PROBLEM",lenyaDoc.getCanonicalDocumentURL(),lenyaDoc.getCanonicalWebappURL(),"");
>                 //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
> "workflow.submit", params);
>                 invoker2.invoke(lenyaDoc.getCanonicalWebappURL(),
> "workflow.publish", params2);
> 
>                 if (invoker2.getResult() != UsecaseInvoker.SUCCESS) {
>                     //A REMETTRE
>                       List messages2 = invoker2.getErrorMessages();
>                     for (Iterator i2 = messages2.iterator();
i2.hasNext();)
> {
>                         UsecaseMessage message2 = (UsecaseMessage)
> i2.next();
>                         //addErrorMessage(message2.getMessage(),
> message2.getParameters());
>                         reportResult("","PROBLEM","USECASE
>
PROBLEM22",message2.getMessage(),Arrays.toString(message2.getParameters()),"");
>                     }
>                 }
>             }
>             catch( ServiceException se){
>                
> reportResult("","PROBLEM2","ServiceException",se.getMessage(),"","");
>             }
>             catch (UsecaseException ue){
>                
> reportResult("","PROBLEM2","UsecaseException",ue.getMessage(),"","");
>             }
>             finally {
>                 if (invoker2 != null) {
>                     this.manager.release(invoker2);
>                 }
>                 }
> }
> 
> Thanks for your help
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Florent André <fl...@4sengines.com>.
On Tue, 12 May 2009 15:08:03 +0200, Andreas Hartmann <an...@apache.org>
wrote:
> [[...]]
> 
> My guess is that:
> 
> * the second usecase invoker (let's call it B) initializes the session 
> SB before the first usecase invoker is called
> 
> * the changes which usecase invoker A makes to session SA are not 
> visible in session SB
> 
> * therefore the document in SB is still in authoring and the workflow 
> transition can't fire
> 
> Is this possible? Would you mind sending the complete code snippet? TIA!

This seems to me a very good possible explanation.
But with invoker I don't use a session explicitly (maybe the problem cause
?). I set-up a session for the creation of the document and commit this
session at the end of doc creation.

Here I send just send you the function that contain invoker. I can send the
full code of my lenyadoctransformer if needed (I hope to publish it one day
:) 

This piece of code is the actual result of many different test (the all
copy-past with 2 is the last)... so be gracefull please :) but i'm really
open to all remark

Here we go : 
private void applyWorkflowState()
        throws ProcessingException, SAXException{

 UsecaseInvoker invoker = null;
            try {
                invoker = (UsecaseInvoker)
this.manager.lookup(UsecaseInvoker.ROLE);
                Map params = new HashMap();
                //params.put(..., ...);
                //invoker.invoke(getSourceUrl(), "publish", params);
                //reportResult("","PROBLEM","USECASE
PROBLEM",lenyaDoc.getCanonicalDocumentURL(),lenyaDoc.getCanonicalWebappU\
RL(),"");
                invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
"workflow.submit", params);
                //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
"workflow.publish", params);

                if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
                    /*A REMETTRE*/
                      List messages = invoker.getErrorMessages();
                    for (Iterator i = messages.iterator(); i.hasNext();) {
                        UsecaseMessage message = (UsecaseMessage) i.next();
                        //addErrorMessage(message.getMessage(),
message.getParameters());
                        reportResult("","PROBLEM","USECASE
PROBLEM",message.getMessage(),Arrays.toString(message.getParameters()),"");
                    }
                }
            }
            catch( ServiceException se){
               
reportResult("","PROBLEM","ServiceException",se.getMessage(),"","");
            }
            catch (UsecaseException ue){
               
reportResult("","PROBLEM","UsecaseException",ue.getMessage(),"","");
            }
            finally {
                if (invoker != null) {
                    this.manager.release(invoker);
                }
            }

            UsecaseInvoker invoker2 = null;
            try {
 UsecaseInvoker invoker2 = null;
            try {
                invoker2 = (UsecaseInvoker)
this.manager.lookup(UsecaseInvoker.ROLE);
                Map params2 = new HashMap();
                //params.put(..., ...);
                //invoker.invoke(getSourceUrl(), "publish", params);
                //reportResult("","PROBLEM","USECASE
PROBLEM",lenyaDoc.getCanonicalDocumentURL(),lenyaDoc.getCanonicalWebappURL(),"");
                //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
"workflow.submit", params);
                invoker2.invoke(lenyaDoc.getCanonicalWebappURL(),
"workflow.publish", params2);

                if (invoker2.getResult() != UsecaseInvoker.SUCCESS) {
                    //A REMETTRE
                      List messages2 = invoker2.getErrorMessages();
                    for (Iterator i2 = messages2.iterator(); i2.hasNext();)
{
                        UsecaseMessage message2 = (UsecaseMessage)
i2.next();
                        //addErrorMessage(message2.getMessage(),
message2.getParameters());
                        reportResult("","PROBLEM","USECASE
PROBLEM22",message2.getMessage(),Arrays.toString(message2.getParameters()),"");
                    }
                }
            }
            catch( ServiceException se){
               
reportResult("","PROBLEM2","ServiceException",se.getMessage(),"","");
            }
            catch (UsecaseException ue){
               
reportResult("","PROBLEM2","UsecaseException",ue.getMessage(),"","");
            }
            finally {
                if (invoker2 != null) {
                    this.manager.release(invoker2);
                }
                }
}

Thanks for your help





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Andreas Hartmann <an...@apache.org>.
Florent André schrieb:
> On Tue, 12 May 2009 14:01:47 +0200, Andreas Hartmann <an...@apache.org>
> wrote:
>> Florent André schrieb:
>>
>> […]
>>
>>>> What are the parameters of the message?
>>> - To see this parameters, I do that in my code :
>>> message.getParameters().toString()
>>> - When I have the error the output is : [Ljava.lang.String;@7f7d2d
>>>
>>> I have to say that I really don't understand what it mean...
>> http://www.javalobby.org/java/forums/t62802.html
> 
> hihi ! :) Ok sorry.
> 
> Now, with the Arrays.toSring(message.getParameters()) I have that [publish,
> 49c679e0-3ef4-11de-ae0f-d221977096c2]...
> 
> Publish is well what I want to do, and 49c... is well the uuid of the
> document I want to publish. This not really help me... :(
> 
> Any usefull tips ?

My guess is that:

* the second usecase invoker (let's call it B) initializes the session 
SB before the first usecase invoker is called

* the changes which usecase invoker A makes to session SA are not 
visible in session SB

* therefore the document in SB is still in authoring and the workflow 
transition can't fire

Is this possible? Would you mind sending the complete code snippet? TIA!

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Florent André <fl...@4sengines.com>.
On Tue, 12 May 2009 14:01:47 +0200, Andreas Hartmann <an...@apache.org>
wrote:
> Florent André schrieb:
> 
> […]
> 
>>> What are the parameters of the message?
>> 
>> - To see this parameters, I do that in my code :
>> message.getParameters().toString()
>> - When I have the error the output is : [Ljava.lang.String;@7f7d2d
>> 
>> I have to say that I really don't understand what it mean...
> 
> http://www.javalobby.org/java/forums/t62802.html

hihi ! :) Ok sorry.

Now, with the Arrays.toSring(message.getParameters()) I have that [publish,
49c679e0-3ef4-11de-ae0f-d221977096c2]...

Publish is well what I want to do, and 49c... is well the uuid of the
document I want to publish. This not really help me... :(

Any usefull tips ?

Thanks


> 
> HTH,
> 
> -- Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Andreas Hartmann <an...@apache.org>.
Florent André schrieb:

[…]

>> What are the parameters of the message?
> 
> - To see this parameters, I do that in my code :
> message.getParameters().toString()
> - When I have the error the output is : [Ljava.lang.String;@7f7d2d
> 
> I have to say that I really don't understand what it mean...

http://www.javalobby.org/java/forums/t62802.html

HTH,

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Florent André <fl...@4sengines.com>.
Thanks for your answer,

On Tue, 12 May 2009 11:59:02 +0200, Andreas Hartmann <an...@apache.org>
wrote:
> Florent André schrieb:
>> Hi Christopher,
>> 
>> Great thanks I can do one step, now I can submit my document.
>> 
>> But I still not arrived to publish my doc... 
>> 
>> My code to submit a Lenya document (that's work, thanks) is [1]. But
when
>> I
>> add the invoker.invoke with "workflow.publish",
> 
> 
>> I have an "error-workflow-document" in my UsecaseMessage
> 
> That usually means the workflow transition coulnd't fire. Are you sure 
> the document is in the correct state and the user has the permission to 
> publish it? 

Yes, this is my test usecase : 
- open an authoring page
- connect with a super-user in Lenya
- open a new tab and fire my pipeline
lenya/dev/modules/docWriter/testwriter

When I just submit my doc with the invoker.invoke, I can publish it in the
user interface (with my super-user).

> What are the parameters of the message?

- To see this parameters, I do that in my code :
message.getParameters().toString()
- When I have the error the output is : [Ljava.lang.String;@7f7d2d

I have to say that I really don't understand what it mean...

[[...]]

Thanks !

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Andreas Hartmann <an...@apache.org>.
Florent André schrieb:
> Hi Christopher,
> 
> Great thanks I can do one step, now I can submit my document.
> 
> But I still not arrived to publish my doc... 
> 
> My code to submit a Lenya document (that's work, thanks) is [1]. But when I
> add the invoker.invoke with "workflow.publish",


> I have an "error-workflow-document" in my UsecaseMessage

That usually means the workflow transition coulnd't fire. Are you sure 
the document is in the correct state and the user has the permission to 
publish it? What are the parameters of the message?

> and my doc is not submitted.
> 
> For doing the submit and publish steps workflow, I try :
> - call the 2 invoker.invoke in the same try/catch
> - copy all the first try/catch with other variables name (invoker2)
> but nothing work...
> 
> I see the workflow.multiWorkflow in cocoon.xconf, but I'm not sure if it's
> a solution for my problem (and I don't really know how to call him in my
> existing code)...

This is the handler for the "Usecase overview" usecase. You can take a 
look at it to see how the usecase invoker is called, but since you have 
already figured that out, I don't think it will be much use to you :)

-- Andreas



> 
> Thanks for your help
> 
> [1]
> UsecaseInvoker invoker = null;
>             try {
>                 invoker = (UsecaseInvoker)
> this.manager.lookup(UsecaseInvoker.ROLE);
>                 Map params = new HashMap();
> 
>                 invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
> "workflow.submit", params);
>                 //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
> "workflow.publish", params);
> 
>                 if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
>                       List messages = invoker.getErrorMessages();
>                     for (Iterator i = messages.iterator(); i.hasNext();) {
>                         UsecaseMessage message = (UsecaseMessage) i.next();
>                         reportResult("","PROBLEM","USECASE
> PROBLEM",message.getMessage(),message.getParameters().toString(),"");
>                     }
>                 }
>             }
>             catch( ServiceException se){
>                
> reportResult("","PROBLEM","ServiceException",se.getMessage(),"","");
>             }
>             catch (UsecaseException ue){
>                
> reportResult("","PROBLEM","UsecaseException",ue.getMessage(),"","");
>             }
>             finally {
>                 if (invoker != null) {
>                     this.manager.release(invoker);
>                 }
>             }
> 
> 
> On Mon, 11 May 2009 12:33:46 +0200, Christopher Wagner
> <wa...@gmail.com> wrote:
>> Hi,
>>
>> this could be done by using the UsecaseInvoker class (Lenya 2.0 API):
>>
>>  UsecaseInvoker invoker = null;
>>      try {
>>          invoker = (UsecaseInvoker)
>>          this.manager.lookup(UsecaseInvoker.ROLE);
>>          Map params = new HashMap();
>>          params.put(..., ...);
>>          invoker.invoke(getSourceUrl(), "publish", params);
>>
>>          if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
>>              List messages = invoker.getErrorMessages();
>>              for (Iterator i = messages.iterator(); i.hasNext();) {
>>                  UsecaseMessage message = (UsecaseMessage) i.next();
>>                  addErrorMessage(message.getMessage(),
>>                  message.getParameters());
>>              }
>>          }
>>      } finally {
>>          if (invoker != null) {
>>              this.manager.release(invoker);
>>          }
>>      }
>>
>>
>> Chris
>>
>> On Mon, May 11, 2009 at 10:23 AM, Florent André <
>> florent.andre-dev@4sengines.com> wrote:
>>
>>> To be more precise :
>>>
>>> On Sun, 10 May 2009 22:14:45 +0200, Florent André
>>> <fl...@4sengines.com> wrote:
>>>> Hi,
>>>>
>>>> I create a lenyaDoc in my code and commit the session : my document is
>>>> in
>>>> the authoring area.
>>>>
>>>> After that I want to publish my lenyaDoc. I try many piece of code,
> but
>>>> nothing work...
>>> No error or exception was thrown, but the document don't appear in my
>>> live
>>> pub.
>>>
>>> If I publish "by hand" my documents they appear in live..
>>>
>>> TIA
>>>
>>>> Can you help me please ?
>>>>
>>>>
>>>> org.apache.cocoon.environment.Session cocoonSession =
>>> request.getSession();
>>>> Identity identity = (Identity)
>>>> cocoonSession.getAttribute(Identity.class.getName());
>>>> Session session = RepositoryUtil.createSession(this.manager, identity,
>>>> true);
>>>>
>>>>
>>>> //Session session = RepositoryUtil.createSession(this.manager, null);
>>>> //Session session = lenyaDoc.getRepositoryNode().getSession();
>>>>
>>>>
>>>> WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
>>>> "submit");
>>>> WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
>>>> "publish");
>>>> session.commit();
>>>>
>>>> Have good day
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>>>> For additional commands, e-mail: user-help@lenya.apache.org
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>>> For additional commands, e-mail: user-help@lenya.apache.org
>>>
>>>


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Florent André <fl...@4sengines.com>.
Hi Christopher,

Great thanks I can do one step, now I can submit my document.

But I still not arrived to publish my doc... 

My code to submit a Lenya document (that's work, thanks) is [1]. But when I
add the invoker.invoke with "workflow.publish", I have an
"error-workflow-document" in my UsecaseMessage and my doc is not submitted.

For doing the submit and publish steps workflow, I try :
- call the 2 invoker.invoke in the same try/catch
- copy all the first try/catch with other variables name (invoker2)
but nothing work...

I see the workflow.multiWorkflow in cocoon.xconf, but I'm not sure if it's
a solution for my problem (and I don't really know how to call him in my
existing code)...

Thanks for your help

[1]
UsecaseInvoker invoker = null;
            try {
                invoker = (UsecaseInvoker)
this.manager.lookup(UsecaseInvoker.ROLE);
                Map params = new HashMap();

                invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
"workflow.submit", params);
                //invoker.invoke(lenyaDoc.getCanonicalWebappURL(),
"workflow.publish", params);

                if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
                      List messages = invoker.getErrorMessages();
                    for (Iterator i = messages.iterator(); i.hasNext();) {
                        UsecaseMessage message = (UsecaseMessage) i.next();
                        reportResult("","PROBLEM","USECASE
PROBLEM",message.getMessage(),message.getParameters().toString(),"");
                    }
                }
            }
            catch( ServiceException se){
               
reportResult("","PROBLEM","ServiceException",se.getMessage(),"","");
            }
            catch (UsecaseException ue){
               
reportResult("","PROBLEM","UsecaseException",ue.getMessage(),"","");
            }
            finally {
                if (invoker != null) {
                    this.manager.release(invoker);
                }
            }


On Mon, 11 May 2009 12:33:46 +0200, Christopher Wagner
<wa...@gmail.com> wrote:
> Hi,
> 
> this could be done by using the UsecaseInvoker class (Lenya 2.0 API):
> 
>  UsecaseInvoker invoker = null;
>      try {
>          invoker = (UsecaseInvoker)
>          this.manager.lookup(UsecaseInvoker.ROLE);
>          Map params = new HashMap();
>          params.put(..., ...);
>          invoker.invoke(getSourceUrl(), "publish", params);
> 
>          if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
>              List messages = invoker.getErrorMessages();
>              for (Iterator i = messages.iterator(); i.hasNext();) {
>                  UsecaseMessage message = (UsecaseMessage) i.next();
>                  addErrorMessage(message.getMessage(),
>                  message.getParameters());
>              }
>          }
>      } finally {
>          if (invoker != null) {
>              this.manager.release(invoker);
>          }
>      }
> 
> 
> Chris
> 
> On Mon, May 11, 2009 at 10:23 AM, Florent André <
> florent.andre-dev@4sengines.com> wrote:
> 
>> To be more precise :
>>
>> On Sun, 10 May 2009 22:14:45 +0200, Florent André
>> <fl...@4sengines.com> wrote:
>> > Hi,
>> >
>> > I create a lenyaDoc in my code and commit the session : my document is
>> > in
>> > the authoring area.
>> >
>> > After that I want to publish my lenyaDoc. I try many piece of code,
but
>> > nothing work...
>>
>> No error or exception was thrown, but the document don't appear in my
>> live
>> pub.
>>
>> If I publish "by hand" my documents they appear in live..
>>
>> TIA
>>
>> >
>> > Can you help me please ?
>> >
>> >
>> > org.apache.cocoon.environment.Session cocoonSession =
>> request.getSession();
>> > Identity identity = (Identity)
>> > cocoonSession.getAttribute(Identity.class.getName());
>> > Session session = RepositoryUtil.createSession(this.manager, identity,
>> > true);
>> >
>> >
>> > //Session session = RepositoryUtil.createSession(this.manager, null);
>> > //Session session = lenyaDoc.getRepositoryNode().getSession();
>> >
>> >
>> > WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
>> > "submit");
>> > WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
>> > "publish");
>> > session.commit();
>> >
>> > Have good day
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>> > For additional commands, e-mail: user-help@lenya.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
>> For additional commands, e-mail: user-help@lenya.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: How to Publish document in Java ?

Posted by Christopher Wagner <wa...@gmail.com>.
Hi,

this could be done by using the UsecaseInvoker class (Lenya 2.0 API):

 UsecaseInvoker invoker = null;
     try {
         invoker = (UsecaseInvoker) this.manager.lookup(UsecaseInvoker.ROLE);
         Map params = new HashMap();
         params.put(..., ...);
         invoker.invoke(getSourceUrl(), "publish", params);

         if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
             List messages = invoker.getErrorMessages();
             for (Iterator i = messages.iterator(); i.hasNext();) {
                 UsecaseMessage message = (UsecaseMessage) i.next();
                 addErrorMessage(message.getMessage(), message.getParameters());
             }
         }
     } finally {
         if (invoker != null) {
             this.manager.release(invoker);
         }
     }


Chris

On Mon, May 11, 2009 at 10:23 AM, Florent André <
florent.andre-dev@4sengines.com> wrote:

> To be more precise :
>
> On Sun, 10 May 2009 22:14:45 +0200, Florent André
> <fl...@4sengines.com> wrote:
> > Hi,
> >
> > I create a lenyaDoc in my code and commit the session : my document is in
> > the authoring area.
> >
> > After that I want to publish my lenyaDoc. I try many piece of code, but
> > nothing work...
>
> No error or exception was thrown, but the document don't appear in my live
> pub.
>
> If I publish "by hand" my documents they appear in live..
>
> TIA
>
> >
> > Can you help me please ?
> >
> >
> > org.apache.cocoon.environment.Session cocoonSession =
> request.getSession();
> > Identity identity = (Identity)
> > cocoonSession.getAttribute(Identity.class.getName());
> > Session session = RepositoryUtil.createSession(this.manager, identity,
> > true);
> >
> >
> > //Session session = RepositoryUtil.createSession(this.manager, null);
> > //Session session = lenyaDoc.getRepositoryNode().getSession();
> >
> >
> > WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
> > "submit");
> > WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
> > "publish");
> > session.commit();
> >
> > Have good day
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> > For additional commands, e-mail: user-help@lenya.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org
>
>

Re: How to Publish document in Java ?

Posted by Florent André <fl...@4sengines.com>.
To be more precise :

On Sun, 10 May 2009 22:14:45 +0200, Florent André
<fl...@4sengines.com> wrote:
> Hi,
> 
> I create a lenyaDoc in my code and commit the session : my document is in
> the authoring area.
> 
> After that I want to publish my lenyaDoc. I try many piece of code, but
> nothing work...

No error or exception was thrown, but the document don't appear in my live
pub. 

If I publish "by hand" my documents they appear in live..

TIA

> 
> Can you help me please ?
> 
> 
> org.apache.cocoon.environment.Session cocoonSession =
request.getSession();
> Identity identity = (Identity)
> cocoonSession.getAttribute(Identity.class.getName());
> Session session = RepositoryUtil.createSession(this.manager, identity,
> true);
> 
> 
> //Session session = RepositoryUtil.createSession(this.manager, null);
> //Session session = lenyaDoc.getRepositoryNode().getSession();
>   
> 
> WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
> "submit");
> WorkflowUtil.invoke(this.manager, session, getLogger(), lenyaDoc,
> "publish");
> session.commit();
> 
> Have good day
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
> For additional commands, e-mail: user-help@lenya.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org