com.sapportals.wcm.command

Class Command

java.lang.Object
  extended by com.sapportals.wcm.command.Command
Direct Known Subclasses:
AttachIndexToFolderCommand, CopyToClipboardCommand, Macro, PasteFromClipboardCommand, QBCUpdateCommand, ResourceCommand

public abstract class Command
extends Object

Command package is a layer between CM repository layer and the user interface. This class provides a uniform execution interface which is directly coupled to user interface components.

Example: RenameCommand can be combined with a input field and a button. The input field can ask for command state (isAccessible(), isSupported(), etc.) and the button action can execute the command.

Furthermore command layer defines a centralized error handling.

Copyright 2004 SAP AG


Constructor Summary
Command()
           
 
Method Summary
 boolean canExecute()
          Check preconditions to execute a command.
protected  boolean canExecuteDefaultImpl()
          Default implementation of canExecute() check.
protected abstract  boolean canExecuteImpl()
          Default implementation of precondition to execute a command.
 boolean execute()
          Executues a command without throwing exceptions.
protected abstract  void executeImpl()
          Implementation to execute a command.
 boolean failed()
           
 String getMessage()
           
 String getMessageKey()
           
 Exception getRootCauseException()
           
 boolean isAccessible()
          Precondition to execute command (access rights are given to execute command).
protected abstract  boolean isAccessibleImpl()
          Implementation to check access rights to execute a command.
 boolean isSupported()
          Precondition to execute command (e.g. supported by repository).
protected abstract  boolean isSupportedImpl()
          Implementation to check if a system configuration supports the execution of a command.
 boolean isSystemError()
          If a command can't generate a resource bundle message key, the error was a system error and the message attribute contains the original exception message.
 void setMessage(String message)
           
 void setMessageKey(String messageKey)
           
protected abstract  void validateImpl()
          Implementation of validation which is called before a command is executed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

public Command()
Method Detail

failed

public boolean failed()

getRootCauseException

public Exception getRootCauseException()

getMessage

public String getMessage()

setMessage

public void setMessage(String message)

getMessageKey

public String getMessageKey()

setMessageKey

public void setMessageKey(String messageKey)

isSystemError

public final boolean isSystemError()
If a command can't generate a resource bundle message key, the error was a system error and the message attribute contains the original exception message.


execute

public final boolean execute()
Executues a command without throwing exceptions. In the case of an exception the exception is handled internally by setting the command into error state (see method failed()). Before execution a validation check is executed.

Returns:
execution state (successful / not successful)

canExecute

public final boolean canExecute()
                         throws com.sapportals.wcm.WcmException
Check preconditions to execute a command.

Throws:
com.sapportals.wcm.WcmException - Must be handled by caller!

isSupported

public final boolean isSupported()
                          throws com.sapportals.wcm.WcmException
Precondition to execute command (e.g. supported by repository).

Throws:
com.sapportals.wcm.WcmException - Must be handled by caller!

isAccessible

public final boolean isAccessible()
                           throws com.sapportals.wcm.WcmException
Precondition to execute command (access rights are given to execute command).

Throws:
com.sapportals.wcm.WcmException - Must be handled by caller!

executeImpl

protected abstract void executeImpl()
                             throws Exception
Implementation to execute a command.

Throws:
Exception - Exceptions are handled generally by the execute() method.

canExecuteDefaultImpl

protected final boolean canExecuteDefaultImpl()
                                       throws com.sapportals.wcm.WcmException
Default implementation of canExecute() check. Can be called in implementation of canExecuteImpl(). (For convenience purpose).

Throws:
com.sapportals.wcm.WcmException - Must be handled by caller!

canExecuteImpl

protected abstract boolean canExecuteImpl()
                                   throws com.sapportals.wcm.WcmException
Default implementation of precondition to execute a command. Usually this is a boolean combination of isAccessible() and isSupported() and others. For convenience the implementation can call canExecuteDefaultImpl().

Throws:
com.sapportals.wcm.WcmException - Must be handled by caller!

isAccessibleImpl

protected abstract boolean isAccessibleImpl()
                                     throws com.sapportals.wcm.WcmException
Implementation to check access rights to execute a command.

Example: To rename a file at least read and write access permission have to be set.

Throws:
com.sapportals.wcm.WcmException - Must be handled by caller!

isSupportedImpl

protected abstract boolean isSupportedImpl()
                                    throws com.sapportals.wcm.WcmException
Implementation to check if a system configuration supports the execution of a command.

Throws:
com.sapportals.wcm.WcmException - Must be handled by caller!

validateImpl

protected abstract void validateImpl()
                              throws ValidationException
Implementation of validation which is called before a command is executed.

Throws:
ValidationException
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] KMC-WPC [sap.com] tc/kmc/wpc/wpcfacade api EP-PIN-WPC-WCM
[sap.com] KMC-CM [sap.com] tc/km/nonwduideprecated api EP-KM-CM


Copyright 2011 SAP AG Complete Copyright Notice