org.deltava.commands
Class AbstractCommand

java.lang.Object
  extended by org.deltava.commands.AbstractCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
AbstractAcademyHistoryCommand, AbstractCalendarCommand, AbstractFormCommand, AbstractLibraryCommand, AbstractTestHistoryCommand, AbstractViewCommand, ACARSDeleteCommand, ActiveServersCommand, AIRACImportCommand, AircraftListCommand, AirlineListCommand, AirlineTotalsCommand, AirportDeleteCommand, AirwayImportCommand, ApplicantApproveCommand, ApplicantDeleteCommand, ApplicantFindCommand, ApplicantRejectCommand, AssignmentCommand, AssignmentDeleteCommand, AssignmentReleaseCommand, AssignmentReserveCommand, AssignmentSaveCommand, AUSOTPlotCommand, BlogCommentCommand, BlogDeleteCommand, BuildCommand, CenturyClubCommand, CenturyClubCommand, CertificationDeleteCommand, CertificationListCommand, ChannelAdminCommand, ChannelDeleteCommand, ChannelDeleteCommand, ChannelListCommand, ChartDeleteCommand, CheckRideAssignCommand, CheckRideCommand, CheckRideFlagCommand, CheckRidePIREPApprovalCommand, CheckRidePIREPCommand, CheckRideScoreCommand, CheckRideScriptDeleteCommand, CheckRideScriptsCommand, ClientVersionCommand, CommandStatsCommand, CommandStatsPurgeCommand, ConnectionInfoDeleteCommand, ContentOverrideCommand, ContentReportCommand, CookieCheckCommand, CourseAssignCommand, CourseCheckRideCommand, CourseCommand, CourseCommentCommand, CourseDeleteCommand, CourseDisposalCommand, CourseProgressCommand, DashboardCommand, DiagnosticCommand, DispatchRouteUpdateCommand, DuplicatePilotCommand, DuplicatePilotMergeCommand, DuplicatePilotSearchCommand, EmoticonHelperCommand, EquipmentProfilesCommand, ErrorLogDeleteCommand, ErrorLogEntryCommand, EventAssignCommand, EventBalanceCommand, EventCancelCommand, EventCommand, EventDeleteCommand, EventEditCommand, EventPlanCommand, EventReleaseCommand, EventSaveCommand, EventSignupCommand, ExamCommand, ExamDeleteCommand, ExamProfilesCommand, ExamScoreCommand, ExamSubmitCommand, ExternalPIREPApprovalCommand, ExternalPIREPCommand, FindFlightCommand, FlightBoardCommand, FlightInfoCommand, FlightInfoDeleteCommand, FlightPreapproveCommand, GalleryDeleteCommand, GalleryImageCommand, GallerySaveCommand, GalleryVoteCommand, HelpDeskCommand, HelpDeskSearchCommand, HomeCommand, IMAPDeleteCommand, InactivityListCommand, InnovataStatusCommand, InstallerStatsCommand, InstructionCancelCommand, InstructorBusyDeleteCommand, InstructorBusySaveCommand, InvalidateEmailCommand, IssueCloseCommand, IssueCommentCommand, IssueCommentCommand, IssueConvertCommand, IssueSearchCommand, IssueUpdateCommand, LeaveCommand, LinkImageCommand, LiveryDeleteCommand, LoginAddressCommand, LoginCommand, LogoutCommand, LogPurgeCommand, LogStatisticsCommand, ManualDeleteCommand, MapCommand, MapCommand, MassMailingCommand, MembershipStatsCommand, MessageTemplateDeleteCommand, MessageTemplatesCommand, NakedCheckRideCommand, NATPlotCommand, NavaidSearchCommand, NewsDeleteCommand, NewsEditCommand, NewsSaveCommand, NOTAMEditCommand, NOTAMSaveCommand, NotificationClearCommand, NotificationListUpdateCommand, NotificationToggleCommand, OfflineFlightCommand, PACOTPlotCommand, PasswordResetCommand, PilotActivationCommand, PilotBoardCommand, PilotLocationCommand, PilotRecognitionCommand, PilotRouteMapCommand, PilotSearchCommand, PIREPDeleteCommand, PIREPDisposalCommand, PIREPReleaseCommand, PIREPSubmitCommand, PostDeleteCommand, PromotionQueueCommand, PromotionToggleCommand, QuestionDeleteCommand, QuestionIncludeCommand, QuestionnaireCommand, QuestionnaireQueueCommand, QuestionnaireScoreCommand, QuestionnaireSubmitCommand, RedirectCommand, RegisterCommand, RegistrationBlockDeleteCommand, ResendValidationCommand, ResendValidationCommand, ResetCommand, ResourceDeleteCommand, ResourceJumpCommand, RetireUserCommand, RouteCommand, RouteCommand, RouteDeleteCommand, RouteDeleteCommand, RouteMapCommand, RoutePlotCommand, RoutePlotCommand, RoutePurgeCommand, RouteSaveCommand, RouteSearchCommand, RouteToggleCommand, ScheduleDeleteCommand, ScheduleExportCommand, ScheduleImportCommand, ScheduleSaveCommand, SecurityRoleMembersCommand, SELCALReserveCommand, ServerDeleteCommand, ServiceEntryDeleteCommand, SignatureApproveCommand, SignatureUpdateCommand, SingleAssignmentBuildCommand, SingleAssignmentSearchCommand, StaffProfileCommand, StaffRosterCommand, StatusCommentCommand, SuspendUserCommand, SystemDataReloadCommand, TaskExecuteCommand, TerminalRouteImportCommand, TerminalRoutePlotCommand, ThreadCommand, ThreadDeleteCommand, ThreadLockCommand, ThreadMoveCommand, ThreadPostCommand, ThreadReplyCommand, ThreadStickCommand, ThreadSubjectEditCommand, ThreadUnlockCommand, ThreadUnstickCommand, TransferAirlineCommand, TransferApproveCommand, TransferConvertCommand, TransferDeleteCommand, TransferProcessCommand, TransferRejectCommand, UnlinkImageCommand, UnreadClearCommand, UnservicedAirportsCommand, UpdateEmailCommand, UpdateRunwayCommand, UpdateTouchdownCommand, UserFileDeleteCommand, UserListCommand, UserSwitchCommand, ValidateEmailCommand, ValidateEMailCommand, WeatherCenterCommand, WelcomeMessageCommand

public abstract class AbstractCommand
extends Object
implements Command

A class to support Web Site Commands.

Since:
1.0
Version:
2.2
Author:
Luke

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.deltava.commands.Command
Command.Scope
 
Field Summary
 
Fields inherited from interface org.deltava.commands.Command
APPLICATION, ID, OPERATION, PAGE, REQUEST, SESSION
 
Constructor Summary
AbstractCommand()
           
 
Method Summary
 String getID()
          Returns the Command ID.
 String getName()
          Returns the Command name.
 Collection<String> getRoles()
          Return the roles authorized to execute this command.
 void init(String id, String cmdName)
          Initializes this command.
protected  CommandException notFoundException(String msg)
          Helper method to generate an "item not found" exception.
protected  Date parseDateTime(CommandContext ctx, String paramHdr)
          Parses one or two HTTP request parameters into a date/time value, using the user's format patterns or the default format patterns if the user is not authenticated.
protected  Date parseDateTime(CommandContext ctx, String paramHdr, String dfmt, String tfmt)
          Parses one or two HTTP request parameters into a date/time value.
protected  CommandException securityException(String msg)
          Helper method to generate a security exception.
 void setRoles(Collection<String> roles)
          Updates the roles authorized to execute this command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.deltava.commands.Command
execute
 

Constructor Detail

AbstractCommand

public AbstractCommand()
Method Detail

init

public void init(String id,
                 String cmdName)
          throws CommandException
Initializes this command.

Specified by:
init in interface Command
Parameters:
cmdName - the name of the command
Throws:
CommandException - if the command name is null
IllegalStateException - if the command has already been initialized

securityException

protected CommandException securityException(String msg)
Helper method to generate a security exception.

Parameters:
msg - the exception message
Returns:
a CommandException

notFoundException

protected CommandException notFoundException(String msg)
Helper method to generate an "item not found" exception.

Parameters:
msg - the exception message
Returns:
a CommandException

getName

public final String getName()
Returns the Command name.

Specified by:
getName in interface Command
Returns:
the name of the command

getID

public final String getID()
Returns the Command ID.

Specified by:
getID in interface Command
Returns:
the command ID

getRoles

public final Collection<String> getRoles()
Return the roles authorized to execute this command. If setRoles() has not been called, this will return an empty Set. Commands defined to be executed by all users should have a wildcard entry (*) as an authorized role.

Specified by:
getRoles in interface Command
Returns:
a Collection of role names
See Also:
setRoles(Collection)

setRoles

public final void setRoles(Collection<String> roles)
Updates the roles authorized to execute this command. This will make a copy of the List object provided (ie. making it immutable) for security reasons.

Specified by:
setRoles in interface Command
Parameters:
roles - the List of role names
Throws:
IllegalStateException - if setRoles() has already been called
See Also:
getRoles()

parseDateTime

protected Date parseDateTime(CommandContext ctx,
                             String paramHdr,
                             String dfmt,
                             String tfmt)
Parses one or two HTTP request parameters into a date/time value. The parameter name header is used to construct the request parameter names. If the request contains a parameter called "$HDR$dateTime", then the parameter will be parsed as a date/time value. If the request contains two parameters named "$HDR$date" and "$HDR$time", then they will be appended and parsed together. If only a single parameter is found, it is parsed appropriately.

Parameters:
ctx - the Command Context
paramHdr - the parameter name header
dfmt - the date format pattern
tfmt - time time format pattern
Returns:
a date/time value, or null if not found or unparseable
See Also:
DateFormat.parse(java.lang.String)

parseDateTime

protected Date parseDateTime(CommandContext ctx,
                             String paramHdr)
Parses one or two HTTP request parameters into a date/time value, using the user's format patterns or the default format patterns if the user is not authenticated.

Parameters:
ctx - the Command Context
paramHdr - the parameter name header
Returns:
a date/time value, or null if not found or unparseable
See Also:
parseDateTime(CommandContext, String, String, String)


Copyright © 2004-2009 Global Virtual Airlines Group. All Rights Reserved.