List Info

Thread: wrong comment and dead code in DocumentUsecase




wrong comment and dead code in DocumentUsecase
user name
2007-01-30 07:24:29
hi *!

obviously, the following code from 
/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/
DocumentUsecase.java 
does not do what the comment claims it does:

/**
  * Returns the document to be redirected to after the
usecase has been
  * completed. If the parameter
<code>success</code> is false, the source
  * document is returned (override this method to change
this behaviour).
  * param success If the usecase was successfully
completed.
  * return A document.
  */
protected Document getTargetDocument(boolean success) {
     Document document = (Document)
getParameter(TARGET_DOCUMENT);
     if (document == null) {
         document = getSourceDocument();
     }
     return document;
}

the "success" parameter is not used.
since the usecase flow handler takes care of unsuccessful
usecase 
submissions, i'd say let's rip this out. wdyt?
can anyone explain why the parameter was originally
introduced?

tia,

jörn


-- 
Jörn Nettingsmeier

"Hofstadter's Law: It always takes longer than you
expect,
even when you take into account Hofstadter's Law."
	- Douglas R. Hofstadter

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribelenya.apache.org
For additional commands, e-mail: dev-helplenya.apache.org


Re: wrong comment and dead code in DocumentUsecase
user name
2007-01-30 10:15:10

Andreas Hartmann wrote:
> Jörn Nettingsmeier schrieb:
>> hi *!
>>
>> obviously, the following code from
>>
/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/
DocumentUsecase.java
>> does not do what the comment claims it does:
>>
>> /**
>>  * Returns the document to be redirected to after
the usecase has been
>>  * completed. If the parameter
<code>success</code> is false, the source
>>  * document is returned (override this method to
change this behaviour).
>>  * param success If the usecase was successfully
completed.
>>  * return A document.
>>  */
>> protected Document getTargetDocument(boolean
success) {
>>     Document document = (Document)
getParameter(TARGET_DOCUMENT);
>>     if (document == null) {
>>         document = getSourceDocument();
>>     }
>>     return document;
>> }
>>
>> the "success" parameter is not used.
>> since the usecase flow handler takes care of
unsuccessful usecase
>> submissions, i'd say let's rip this out. wdyt?
> 
> The flowscript passes the success parameter to the
usecase,
> so it can be taken into account:
> 
>     targetUrl = usecase.getTargetURL(state ==
"success");
> 
> I wouldn't like to remove it, because I can imagine
that some
> usecases want to use custom target URLs for
non-successful
> invocation (i.e., the URL of an alternative usecase or
a certain
> error page).

ok, but then let's either fix the comment, or change the
implementation to
  protected Document getTargetDocument(boolean success) {
      if (!success) return getSourceDocument();
      Document document = (Document)
getParameter(TARGET_DOCUMENT);
      if (document == null) {
          document = getSourceDocument();
      }
      return document;
  }

or am i missing something?


-- 
jörn nettingsmeier

home://germany/45128 essen/lortzingstr. 11/
http://spunk.dnsalias.org
phone://+49/201/491621

if you are a free (as in "free speech") software
developer
and you happen to be travelling near my home, drop me a
line
and come round for a free (as in "free beer")
beer. :-D

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribelenya.apache.org
For additional commands, e-mail: dev-helplenya.apache.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )