Project: * Clean-up (Eclipse cruft, unused files, etc...) * Git-specific changes * Maven POMs clean-up and changes for the build system * Version set to 1.0.0-0 in the development branches * Maven plug-ins updated to latest versions * Very partial dev. documentation added

This commit is contained in:
Emmanuel BENOîT 2011-12-09 08:07:33 +01:00
parent c74e30d5ba
commit 0665a760de
1439 changed files with 1020 additions and 1649 deletions
legacyworlds-server-interfaces/src
main
java/com/deepclone/lw/interfaces
acm
admin
bt
eventlog
game
i18n
mailer
msg
naming
prefs
session
sys
resources
test
java
resources

View file

@ -0,0 +1,10 @@
package com.deepclone.lw.interfaces.acm;
public class AccountMailException
extends Exception
{
private static final long serialVersionUID = 1L;
}

View file

@ -0,0 +1,112 @@
package com.deepclone.lw.interfaces.acm;
import java.net.InetAddress;
import java.util.List;
import java.util.Map;
import com.deepclone.lw.cmd.admin.adata.Administrator;
import com.deepclone.lw.cmd.admin.users.AccountListEntry;
import com.deepclone.lw.cmd.admin.users.AccountSessionEntry;
import com.deepclone.lw.cmd.admin.users.AccountStatus;
import com.deepclone.lw.cmd.admin.users.AccountViewEntry;
import com.deepclone.lw.cmd.admin.users.SessionTerminationType;
import com.deepclone.lw.cmd.player.account.BanDetailsResponse;
import com.deepclone.lw.cmd.player.gdata.account.AccountData;
import com.deepclone.lw.interfaces.i18n.TranslationException;
import com.deepclone.lw.interfaces.mailer.MailerException;
import com.deepclone.lw.sqld.accounts.Account;
import com.deepclone.lw.sqld.accounts.ValidationResult;
import com.deepclone.lw.utils.EmailAddress;
import com.deepclone.lw.utils.Password;
public interface AccountManagement
{
public void createAccount( EmailAddress address , Password password , String language )
throws AccountMailException , MailerException , TranslationException;
public ValidationResult validateAccount( EmailAddress address , String token , String empire , String planet );
public void reactivateAccount( EmailAddress address )
throws AccountMailException , MailerException;
public void requestPasswordRecovery( EmailAddress address )
throws AccountMailException , MailerException , PasswordRecoveryException;
public void recoverPassword( EmailAddress address , String token , Password password )
throws AccountMailException , PasswordRecoveryException , PasswordProhibitedException;
public AccountSession login( EmailAddress address , String challenge , String sha1Hash , String md5Hash ,
InetAddress ipAddress , String clientType , String sessionName );
public void logout( long session , SessionTerminationType reason );
public Account restoreSession( long session );
public Account getAccount( EmailAddress address );
public List< String > getEmpireNames( EmailAddress address );
public AccountData getAccountPage( EmailAddress address );
public void setLanguage( EmailAddress address , String language );
public boolean setPassword( EmailAddress address , String challenge , String sha1Hash , String md5Hash ,
Password newPassword )
throws PasswordProhibitedException;
public boolean setAddress( EmailAddress address , String challenge , String sha1Auth , String md5Auth ,
EmailAddress nAddress )
throws AccountMailException , MailerException;
public void cancelAddressChange( EmailAddress cAddress );
public AccountData confirmAddressChange( EmailAddress cAddress , String code );
public void resetPreferences( EmailAddress address );
public void setPreferences( EmailAddress address , Map< String , String > values );
public void setQuit( EmailAddress address , String reason );
public void cancelQuit( EmailAddress address );
public void toggleVacation( EmailAddress address );
public List< AccountListEntry > listAccounts( AccountStatus status , boolean online );
public AccountViewEntry getAccountView( int id );
public AccountSessionEntry viewSessions( int id );
public void giveCredits( Administrator admin , int id , int credits );
public BanDetailsResponse getBanDetails( EmailAddress address );
}

View file

@ -0,0 +1,20 @@
package com.deepclone.lw.interfaces.acm;
import com.deepclone.lw.sqld.accounts.Account;
public class AccountSession
{
public final Account account;
public final long session;
public AccountSession( Account account , long session )
{
this.account = account;
this.session = session;
}
}

View file

@ -0,0 +1,17 @@
package com.deepclone.lw.interfaces.acm;
public class EmailChangeException
extends Exception
{
private static final long serialVersionUID = 1L;
public final boolean statusProblem;
public EmailChangeException( boolean statusProblem )
{
this.statusProblem = statusProblem;
}
}

View file

@ -0,0 +1,28 @@
package com.deepclone.lw.interfaces.acm;
import com.deepclone.lw.interfaces.naming.EmpireNameException;
import com.deepclone.lw.interfaces.naming.MapNameException;
public class JoinGameException
extends Exception
{
private static final long serialVersionUID = 1L;
public final boolean validated;
public final EmpireNameException.Error empireNameError;
public final MapNameException.Error mapNameError;
public JoinGameException( boolean validated , EmpireNameException.Error empireNameError ,
MapNameException.Error mapNameError )
{
this.validated = validated;
this.empireNameError = empireNameError;
this.mapNameError = mapNameError;
}
}

View file

@ -0,0 +1,10 @@
package com.deepclone.lw.interfaces.acm;
public class PasswordProhibitedException
extends Exception
{
private static final long serialVersionUID = 1L;
}

View file

@ -0,0 +1,17 @@
package com.deepclone.lw.interfaces.acm;
public class PasswordRecoveryException
extends Exception
{
private static final long serialVersionUID = 1L;
public final boolean statusProblem;
public PasswordRecoveryException( boolean statusProblem )
{
this.statusProblem = statusProblem;
}
}

View file

@ -0,0 +1,9 @@
package com.deepclone.lw.interfaces.acm;
public class PermanentlyDisabledException
extends Exception
{
private static final long serialVersionUID = 1L;
}

View file

@ -0,0 +1,28 @@
package com.deepclone.lw.interfaces.acm;
import java.util.List;
import com.deepclone.lw.cmd.admin.users.SessionTerminationType;
import com.deepclone.lw.cmd.admin.users.UserSession;
public interface UserSessionDAO
{
public long startSession( int id , String sName , String client , String address );
public void endSession( long session , SessionTerminationType termination );
public UserSession getSession( long id );
public boolean isOnline( int id );
public List< UserSession > getSessions( int id );
}

View file

@ -0,0 +1,107 @@
package com.deepclone.lw.interfaces.acm;
import java.util.List;
import com.deepclone.lw.cmd.admin.users.AccountListEntry;
import com.deepclone.lw.cmd.admin.users.AccountStatus;
import com.deepclone.lw.cmd.admin.users.AccountViewEntry;
import com.deepclone.lw.cmd.player.gdata.account.MailChangeData;
import com.deepclone.lw.sqld.accounts.Account;
import com.deepclone.lw.sqld.accounts.AccountOperationResult;
import com.deepclone.lw.sqld.accounts.QuittingAccount;
import com.deepclone.lw.sqld.accounts.ValidationResult;
import com.deepclone.lw.utils.EmailAddress;
import com.deepclone.lw.utils.Password;
public interface UsersDAO
{
public Account getAccount( EmailAddress address );
public Account getAccount( int id );
public AccountOperationResult createAccount( EmailAddress address , Password password , String language );
public Account reactivateAccount( EmailAddress address );
public void cancelAccountValidation( Account account );
public ValidationResult validateAccount( EmailAddress address , String token , String eName , String pName );
public AccountOperationResult requestPasswordRecovery( EmailAddress address );
public void cancelPasswordRecovery( Account account );
public AccountOperationResult confirmPasswordRecovery( EmailAddress address , String token , Password nPassword );
public MailChangeData getMailChange( int accountId );
public void setLanguage( EmailAddress address , String language );
public boolean setPassword( Account account , Password newPassword );
public int setAddress( Account account , EmailAddress nAddress );
public void cancelAddressChange( Account account );
public int confirmAddressChange( Account account , String code );
public void expireRequests( );
public void setQuit( Account account , String reason );
public void cancelQuit( Account account );
public List< QuittingAccount > processQuits( );
public void enterVacation( Account account );
public void leaveVacation( Account account );
public void processVacations( );
public List< AccountListEntry > listAccounts( AccountStatus status );
public List< AccountListEntry > listOnlineAccounts( AccountStatus status );
public AccountViewEntry viewAccount( int id );
public void giveCredits( int adminId , int accountId , int credits );
public void deleteOldAccounts( );
public List< QuittingAccount > getInactivesToWarn( );
public List< QuittingAccount > getInactivesToDisable( );
}

View file

@ -0,0 +1,56 @@
package com.deepclone.lw.interfaces.admin;
import java.net.InetAddress;
import java.sql.Timestamp;
import java.util.List;
import com.deepclone.lw.cmd.admin.adata.AdminOverview;
import com.deepclone.lw.sqld.admin.AdminConnection;
import com.deepclone.lw.sqld.admin.AdminRecord;
import com.deepclone.lw.utils.EmailAddress;
public interface AdminDAO
{
public AdminRecord getAdmin( int id );
public AdminRecord getAdmin( EmailAddress address );
public AdminRecord getAdmin( String name );
public int createAdmin( String address , String name , int privileges )
throws AdminDAOException;
public void logConnectionAttempt( int id , AdminConnection status , InetAddress address );
public void logDisconnection( int id );
public boolean setPassword( int id , String sha1 , String md5 );
public List< AdminRecord > listAdministrators( );
public boolean resetPassword( int identifier , int superuser );
public boolean setPrivileges( int identifier , int superuser , int privileges );
public AdminOverview getOverview( int id );
public List< AdminOverview > getOverviews( );
public Timestamp isRecapTime( );
}

View file

@ -0,0 +1,24 @@
package com.deepclone.lw.interfaces.admin;
public class AdminDAOException
extends Exception
{
private static final long serialVersionUID = 1L;
private final int errorCode;
public AdminDAOException( int errorCode )
{
this.errorCode = errorCode;
}
public int getErrorCode( )
{
return errorCode;
}
}

View file

@ -0,0 +1,71 @@
package com.deepclone.lw.interfaces.admin;
import java.net.InetAddress;
import java.util.List;
import java.util.Set;
import com.deepclone.lw.cmd.admin.AdminOverviewResponse;
import com.deepclone.lw.cmd.admin.adata.Administrator;
import com.deepclone.lw.cmd.admin.adata.Privileges;
import com.deepclone.lw.cmd.admin.bans.BanType;
import com.deepclone.lw.cmd.admin.bans.BansSummaryResponse;
import com.deepclone.lw.cmd.admin.bans.ListBansResponse;
import com.deepclone.lw.cmd.admin.bans.RequestBanResponse;
import com.deepclone.lw.cmd.admin.su.AddAdministratorResponse;
import com.deepclone.lw.interfaces.acm.PasswordProhibitedException;
import com.deepclone.lw.sqld.admin.AdminRecord;
import com.deepclone.lw.utils.EmailAddress;
import com.deepclone.lw.utils.Password;
public interface Administration
{
public AdminRecord getAdmin( int id );
public AdminRecord login( EmailAddress address , String challenge , String sha1Hash , String md5Hash ,
InetAddress ipAddress );
public void logout( int adminId );
public boolean setPassword( int id , String challenge , String sha1Auth , String md5Auth , Password password )
throws PasswordProhibitedException;
public List< AdminRecord > listAdministrators( );
public AddAdministratorResponse createAdmin( Administrator creator , String address , String name , int privileges );
public AdminRecord resetPassword( Administrator admin , int identifier );
public AdminRecord setPrivileges( Administrator admin , int identifier , Set< Privileges > privileges );
public BansSummaryResponse getBansSummary( Administrator admin );
public ListBansResponse getBans( Administrator admin , BanType type );
public RequestBanResponse requestBan( Administrator admin , String user , boolean empire , String reason );
public void rejectBan( Administrator admin , int id , String reason );
public void confirmBan( Administrator admin , int id );
public void liftBan( Administrator admin , int id );
public AdminOverviewResponse getOverview( Administrator admin );
}

View file

@ -0,0 +1,27 @@
package com.deepclone.lw.interfaces.admin;
public class BanMailData
{
public final String address;
public final String language;
public final String reason;
public BanMailData( String address , String language , String reason )
{
this.address = address;
this.language = language;
this.reason = reason;
}
public BanMailData( String address , String language )
{
this.address = address;
this.language = language;
this.reason = null;
}
}

View file

@ -0,0 +1,54 @@
package com.deepclone.lw.interfaces.admin;
import java.util.List;
import com.deepclone.lw.cmd.admin.bans.BanRequest;
import com.deepclone.lw.cmd.admin.bans.SummaryEntry;
import com.deepclone.lw.cmd.admin.bans.ValidatedBanRequest;
import com.deepclone.lw.utils.EmailAddress;
public interface BansDAO
{
public List< SummaryEntry > getSummary( );
public List< BanRequest > getPending( );
public List< BanRequest > getArchived( );
public List< BanRequest > getActive( );
public int requestBan( int administrator , EmailAddress address , String reason );
public int requestBan( int administrator , String empire , String reason );
public void rejectBan( int administrator , int requestId , String reason );
public BanMailData validateBan( int administrator , int requestId );
public BanMailData liftBan( int administrator , int requestId );
public void expireBanRequests( );
public void expireWarnings( );
public boolean finaliseBan( );
public ValidatedBanRequest getActiveBan( EmailAddress address );
}

View file

@ -0,0 +1,33 @@
package com.deepclone.lw.interfaces.admin;
import java.net.InetAddress;
/**
* This interface is used to check if an IP address is banned.
*
* @author tseeker
*/
public interface IpBan
{
/**
* Checks if the InetAddress provided is banned.
*
* @param address
* the IP Address to be checked
* @return a boolean saying whether or not the address is banned.
*/
public boolean isBanned( InetAddress address );
/**
* Increases the ban counter associated with the given address.
*
* @param address
* the IP Address to be added to the counter.
*/
public void increaseBanCounter( InetAddress address );
}

View file

@ -0,0 +1,45 @@
package com.deepclone.lw.interfaces.bt;
import com.deepclone.lw.cmd.bt.data.*;
import com.deepclone.lw.cmd.admin.adata.Administrator;
import com.deepclone.lw.cmd.admin.bt.*;
public interface AdminBugs
{
public BugsSummaryResponse getSummary( Administrator admin );
public ListBugsResponse getBugs( Administrator admin , BugStatus status , boolean ownOnly , long first , int count );
public ReportBugResponse postReport( Administrator admin , String title , String contents , boolean publicReport );
ViewBugResponse getReport( Administrator admin , long bugId );
public PostCommentResponse postComment( Administrator admin , long bugId , String comment , boolean publicComment );
public void moderateComment( Administrator admin , long commentId , boolean validation );
public void validateReport( Administrator admin , long bugId , BugStatus status , boolean publicReport , int credits, boolean snapshot );
public void setStatus( Administrator admin , long bugId , BugStatus status );
public void toggleVisibility( Administrator admin , long bugId );
public MergeReportsResponse mergeReports( Administrator admin , long id , long mergeId );
public GetSnapshotResponse getSnapshot( Administrator admin , long bugId );
}

View file

@ -0,0 +1,71 @@
package com.deepclone.lw.interfaces.bt;
import java.util.List;
import com.deepclone.lw.cmd.admin.adata.Administrator;
import com.deepclone.lw.cmd.bt.data.*;
public interface BugsDAO
{
public long countReports( int empireId , BugStatus status , boolean ownOnly );
public long countReports( Administrator admin , BugStatus status , boolean ownOnly );
public long countUpdatedReports( Administrator admin );
public List< BugReport > getReports( int empireId , BugStatus status , boolean ownOnly , long first , int count );
public List< BugReport > getReports( Administrator admin , BugStatus status , boolean ownOnly , long first ,
int count );
public BugReport getReport( int empireId , long reportId );
public BugReport getReport( Administrator admin , long reportId );
public long postReport( int empireId , String title , String contents , String extra );
public long postReport( Administrator admin , String title , String contents , boolean publicReport );
public void postComment( int empireId , long reportId , String comment );
public void postComment( Administrator admin , long reportId , String comment , boolean publicComment );
public List< BugEvent > getEvents( long bugId );
public void showComment( Administrator admin , long commentId );
public void deleteComment( Administrator admin , long commentId );
public void validateReport( Administrator admin , long bugId , BugStatus status , boolean publicReport , int credits, boolean snapshot );
public void setStatus( Administrator admin , long bugId , BugStatus status );
public void toggleVisibility( Administrator admin , long bugId );
public int mergeReports( Administrator admin , long id , long mergeId );
public String getSnapshot( long bugId );
}

View file

@ -0,0 +1,9 @@
package com.deepclone.lw.interfaces.bt;
public interface EmpireSummary
{
public String getSummary( int empireId );
}

View file

@ -0,0 +1,23 @@
package com.deepclone.lw.interfaces.bt;
import com.deepclone.lw.cmd.bt.data.*;
import com.deepclone.lw.cmd.player.bt.*;
public interface PlayerBugs
{
public ListBugsResponse getBugs( int empireId , BugStatus status , boolean ownOnly , long first , int count );
public ReportBugResponse postReport( int empireId , String title , String desc );
ViewBugResponse getReport( int empireId , long bugId );
public PostCommentResponse postComment( int empireId , long reportId , String comment );
}

View file

@ -0,0 +1,24 @@
package com.deepclone.lw.interfaces.eventlog;
import java.util.List;
import com.deepclone.lw.cmd.admin.logs.ExceptionEntry;
import com.deepclone.lw.cmd.admin.logs.LogEntry;
public class ExtendedLogEntry
{
public final LogEntry logEntry;
public final List< ExceptionEntry > exceptions;
public ExtendedLogEntry( LogEntry logEntry , List< ExceptionEntry > exceptions )
{
this.logEntry = logEntry;
this.exceptions = exceptions;
}
}

View file

@ -0,0 +1,31 @@
package com.deepclone.lw.interfaces.eventlog;
import java.sql.Timestamp;
import java.util.List;
import com.deepclone.lw.cmd.admin.adata.Administrator;
import com.deepclone.lw.cmd.admin.logs.GetEntryResponse;
import com.deepclone.lw.cmd.admin.logs.LogEntry;
import com.deepclone.lw.cmd.admin.logs.LogLevel;
import com.deepclone.lw.cmd.admin.logs.LogType;
import com.deepclone.lw.cmd.admin.logs.ViewLogResponse;
public interface LogReader
{
public ViewLogResponse getLog( Administrator admin , LogType type , long first , int count , LogLevel minLevel ,
String component , boolean excOnly );
public GetEntryResponse getEntry( Administrator admin , long id );
public List< ExtendedLogEntry > getErrorEntries( );
public List< LogEntry > getAdminLogSince( Timestamp timestamp );
}

View file

@ -0,0 +1,27 @@
package com.deepclone.lw.interfaces.eventlog;
import java.util.List;
import com.deepclone.lw.sqld.sys.SystemLogEntry;
/**
* This interface is used by the server's log writer bean. It implements an asynchronous log writer
* that uses the database to store log entries.
*
* @author tseeker
*/
public interface LogWriter
{
/**
* Adds a list of log entries to the queue of messages to write.
*
* @param entries
* the entries to write
*/
public void addEntries( List< SystemLogEntry > entries );
}

View file

@ -0,0 +1,21 @@
package com.deepclone.lw.interfaces.eventlog;
/**
* This interface is used by the server's in-base logger.
*
* @author tseeker
*/
public interface Logger
{
/**
* Creates a logger for system actions, using the specified string as the component's name.
*
* @param component
* the name of the component producing log entries
* @return a {@link SystemLogger} for the specified component
*/
public SystemLogger getSystemLogger( String component );
}

View file

@ -0,0 +1,49 @@
package com.deepclone.lw.interfaces.eventlog;
import com.deepclone.lw.cmd.admin.logs.LogLevel;
/**
* A SystemLogger is capable of writing basic, system-related entries to the database.
*
* @author tseeker
*/
public interface SystemLogger
{
/**
* Writes a log entry.
*
* @param level
* the entry's log level
* @param message
* the text of the log entry
* @return the logger
*/
public SystemLogger log( LogLevel level , String message );
/**
* Writes a log entry and an associated exception
*
* @param level
* the entry's log level
* @param message
* the text of the log entry
* @param exception
* the exception to associate to the log entry
* @return the logger
*/
public SystemLogger log( LogLevel level , String message , Throwable exception );
/**
* Flushes a logger's entries to the main logger bean.
*
* @return the logger
*/
public SystemLogger flush( );
}

View file

@ -0,0 +1,49 @@
package com.deepclone.lw.interfaces.game;
import com.deepclone.lw.cmd.player.gdata.alliance.AllianceLeaderData;
import com.deepclone.lw.cmd.player.gdata.alliance.AllianceMemberData;
import com.deepclone.lw.cmd.player.gdata.alliance.PublicAllianceInformation;
import com.deepclone.lw.sqld.game.AllianceMembership;
public interface AllianceDAO
{
public AllianceMembership getAlliance( int empireId );
public Integer findAlliance( String tag );
public Integer createAlliance( int empireId , String tag , String name );
public PublicAllianceInformation getPublicInformation( int allianceId );
public AllianceMemberData getMemberData( int allianceId );
public AllianceLeaderData getLeaderData( int allianceId );
public boolean requestJoin( int empireId , int allianceId );
public void cancelJoin( int empireId );
public void leave( int empireId );
public void transferLeadership( int empireId , int toMember );
public void manageRequests( int empireId , boolean accept , int[] members );
public void kick( int empireId , int[] members );
}

View file

@ -0,0 +1,36 @@
package com.deepclone.lw.interfaces.game;
import com.deepclone.lw.cmd.player.alliances.AllianceStatusResponse;
public interface AllianceManagement
{
public AllianceStatusResponse getView( int empireId );
public AllianceStatusResponse getInformation( int empireId , String tag );
public AllianceStatusResponse create( int empireId , String tag , String name );
public AllianceStatusResponse requestJoin( int empireId , String tag );
public AllianceStatusResponse cancelJoin( int empireId );
public AllianceStatusResponse leave( int empireId );
public AllianceStatusResponse transferLeadership( int empireId , int toMember );
public AllianceStatusResponse manageRequests( int empireId , boolean accept , int[] members );
public AllianceStatusResponse kick( int empireId , int[] members );
}

View file

@ -0,0 +1,19 @@
package com.deepclone.lw.interfaces.game;
import com.deepclone.lw.cmd.player.battles.GetBattleResponse;
import com.deepclone.lw.cmd.player.battles.ListBattlesResponse;
public interface BattleViewer
{
public GetBattleResponse getBattle( int empireId , long battleId );
public GetBattleResponse getBattle( int empireId , long battleId , long tick );
public ListBattlesResponse getBattles( int empireId , int page );
}

View file

@ -0,0 +1,8 @@
package com.deepclone.lw.interfaces.game;
public interface BattlesCache
extends BattlesDAO
{
// EMPTY
}

View file

@ -0,0 +1,36 @@
package com.deepclone.lw.interfaces.game;
import java.util.List;
import java.util.Map;
import com.deepclone.lw.sqld.game.battle.*;
public interface BattlesDAO
{
public EmpireBattleRecord getBattleRecord( int empireId , long battleId );
public List< PresenceRecord > getPresence( EmpireBattleRecord record );
public List< EventRecord > getEvents( EmpireBattleRecord record );
public Map< Boolean , Map< Long , List< EventItemRecord >>> getEventItems( EmpireBattleRecord record );
public Map< Long , Map< Long , ProtagonistRecord >> getProtagonists( EmpireBattleRecord record );
public Map< Long , List< BuildingHistoryRecord >> getBuildingsHistory( EmpireBattleRecord record );
public Map< Long , Map< Long , List< ShipHistoryRecord >>> getShipsHistory( EmpireBattleRecord record );
List< BattleListRecord > getBattles( int empireId );
}

View file

@ -0,0 +1,46 @@
package com.deepclone.lw.interfaces.game;
import java.util.List;
import com.deepclone.lw.cmd.ObjectNameError;
import com.deepclone.lw.cmd.player.gdata.NameIdPair;
import com.deepclone.lw.cmd.player.gdata.PlanetListData;
import com.deepclone.lw.cmd.player.gdata.empire.OverviewData;
import com.deepclone.lw.sqld.game.EmpireTechLine;
import com.deepclone.lw.sqld.game.GeneralInformation;
public interface EmpireDAO
{
public GeneralInformation getInformation( int empireId );
public List< NameIdPair > getPlanets( int empireId );
public OverviewData getOverview( int empireId );
public List< EmpireTechLine > getTechnology( int empireId );
public void implementTechnology( int empireId , int lineId );
public List< PlanetListData > getPlanetList( int empireId );
public List< NameIdPair > getEnemies( int empireId , boolean alliances );
public ObjectNameError addEnemy( int empireId , boolean alliance , String name );
public void removeEnemies( int empireId , boolean alliance , int[] ids );
public int getNewPlanet( int empireId , String name );
}

View file

@ -0,0 +1,41 @@
package com.deepclone.lw.interfaces.game;
import com.deepclone.lw.cmd.player.GetNewPlanetResponse;
import com.deepclone.lw.cmd.player.ListPlanetsResponse;
import com.deepclone.lw.cmd.player.EmpireResponse;
import com.deepclone.lw.cmd.player.elist.EnemyListResponse;
import com.deepclone.lw.cmd.player.gdata.GamePageData;
import com.deepclone.lw.utils.EmailAddress;
public interface EmpireManagement
{
public Integer getEmpireId( EmailAddress address );
public GamePageData getGeneralInformation( int empireId );
public EmpireResponse getOverview( int empireId );
public EmpireResponse implementTechnology( int empireId , int techId );
public ListPlanetsResponse getPlanetList( int empireId );
public EnemyListResponse getEnemyLists( int empireId );
public EnemyListResponse addEnemy( int empireId , boolean alliance , String name );
public EnemyListResponse removeEnemies( int empireId , boolean alliance , int[] ids );
public GetNewPlanetResponse getNewPlanet( int empireId , String name );
}

View file

@ -0,0 +1,36 @@
package com.deepclone.lw.interfaces.game;
import java.util.Map;
import com.deepclone.lw.cmd.player.fleets.MultiFleetsResponse;
import com.deepclone.lw.cmd.player.fleets.SplitFleetResponse;
import com.deepclone.lw.cmd.player.fleets.ViewFleetsResponse;
public interface FleetManagement
{
public ViewFleetsResponse getFleets( int empireId );
public MultiFleetsResponse move( int empireId , long[] fleets , String destination , boolean attack );
public MultiFleetsResponse setMode( int empireId , long[] fleets , boolean attack , boolean doIt );
public MultiFleetsResponse rename( int empireId , long[] fleets , String name );
public MultiFleetsResponse merge( int empireId , long[] fleets );
public SplitFleetResponse split( int empireId , long fleetId , Map< Integer , Integer > ships , int nFleets ,
String name , boolean simulate );
public MultiFleetsResponse disband( int empireId , long[] fleets , boolean doIt );
}

View file

@ -0,0 +1,50 @@
package com.deepclone.lw.interfaces.game;
import java.util.List;
import com.deepclone.lw.cmd.player.gdata.fleets.FleetsView;
import com.deepclone.lw.cmd.player.gdata.fleets.ShortFleetView;
import com.deepclone.lw.cmd.player.gdata.fleets.SplitShips;
public interface FleetsDAO
{
public FleetsView getFleets( int empireId );
public List< ShortFleetView > getShortFleets( int empireId , long[] fleets , boolean needsAvailable );
public ShortFleetView getShortFleet( int empireId , long fleetId );
public boolean move( int empireId , long[] fleets , String destination );
public void setMode( int empireId , long[] fleets , boolean attack );
public void rename( int empireId , long[] fleets , String name );
public void merge( int empireId , long[] fleets );
public void disband( int empireId , long[] fleets );
public List< SplitShips > getShips( int empireId , long fleetId );
public boolean initSplit( long fleetId , int nFleets , String name );
public void setSplitShips( int shipType , int amount );
public boolean executeSplit( boolean simulate );
}

View file

@ -0,0 +1,23 @@
package com.deepclone.lw.interfaces.game;
import com.deepclone.lw.cmd.player.gdata.MapSize;
public class MapViewParameters
{
public final int x;
public final int y;
public final MapSize size;
public MapViewParameters( int x , int y , MapSize size )
{
this.x = x;
this.y = y;
this.size = size;
}
}

View file

@ -0,0 +1,17 @@
package com.deepclone.lw.interfaces.game;
import com.deepclone.lw.cmd.player.gdata.map.MapSystemData;
import com.deepclone.lw.utils.EmailAddress;
public interface MapViewer
{
public MapViewParameters getDefaults( EmailAddress address );
public MapSystemData[][] getMapView( int empireId , MapViewParameters parameters );
}

View file

@ -0,0 +1,58 @@
package com.deepclone.lw.interfaces.game;
import java.util.List;
import com.deepclone.lw.cmd.player.gdata.planets.BuildableBuildingData;
import com.deepclone.lw.cmd.player.gdata.planets.BuildableShipData;
import com.deepclone.lw.cmd.player.gdata.planets.BuildingData;
import com.deepclone.lw.cmd.player.gdata.planets.QueueData;
import com.deepclone.lw.sqld.game.PlanetData;
public interface PlanetDAO
{
public PlanetData.Basic getBasicInformation( int empireId , int planetId );
public PlanetData.Orbital getOrbitalInformation( int empireId , int planetId );
public PlanetData.Owner getOwnerInformation( int empireId , int planetId );
public List< BuildingData > getBuildings( int empireId , int planetId , boolean isOwner );
public QueueData getConstructionQueue( int planetId );
public QueueData getMilitaryQueue( int planetId );
public List< BuildableBuildingData > getAvailableBuildings( int planetId );
public List< BuildableShipData > getAvailableShips( int planetId );
public void flushQueue( int planetId , boolean military );
public void addToMilitaryQueue( int planetId , int sType , int amount );
public void constructBuildings( int planetId , int bType , int amount );
public boolean destroyBuildings( int planetId , int bType , int amount );
public Integer abandon( int planetId );
public void cancelAbandon( int planetId );
}

View file

@ -0,0 +1,31 @@
package com.deepclone.lw.interfaces.game;
import com.deepclone.lw.cmd.player.planets.ViewPlanetResponse;
public interface PlanetsManagement
{
public ViewPlanetResponse viewPlanet( int empireId , int planetId );
public ViewPlanetResponse renamePlanet( int empireId , int planetId , String name );
public ViewPlanetResponse flushQueue( int empireId , int planetId , boolean military );
public ViewPlanetResponse addToMilitaryQueue( int empireId , int planetId , int sType , int amount );
public ViewPlanetResponse addToCivilianQueue( int empireId , int planetId , int bType , boolean destroy , int amount );
public ViewPlanetResponse abandon( int empireId , int planetId );
public ViewPlanetResponse cancelAbandon( int empireId , int planetId );
}

View file

@ -0,0 +1,18 @@
package com.deepclone.lw.interfaces.game;
import java.util.List;
import com.deepclone.lw.sqld.game.MapData;
public interface UniverseDAO
{
public void generate( );
public List< MapData > getMap( int empireId , int minX , int minY , int maxX , int maxY );
}

View file

@ -0,0 +1,7 @@
package com.deepclone.lw.interfaces.game;
public interface UpdatesDAO
{
public boolean processUpdates( long tickId );
}

View file

@ -0,0 +1,22 @@
package com.deepclone.lw.interfaces.i18n;
/**
* This exception is thrown by the administration session object if the creation of a language is
* requested using an identifier that is already present in the database.
*
* @author tseeker
*/
public class DuplicateLanguageException
extends I18NException
{
private static final long serialVersionUID = 1L;
public DuplicateLanguageException( String message )
{
super( message );
}
}

View file

@ -0,0 +1,22 @@
package com.deepclone.lw.interfaces.i18n;
/**
* This exception is thrown by the administration session object when the creation of a string is
* requested and the new string's identifier is already in use.
*
* @author tseeker
*/
public class DuplicateStringException
extends I18NException
{
private static final long serialVersionUID = 1L;
public DuplicateStringException( String message )
{
super( message );
}
}

View file

@ -0,0 +1,143 @@
package com.deepclone.lw.interfaces.i18n;
import java.util.Map;
import java.util.Set;
/**
* Translations database administration session
*
* This interface defines the various methods allowing an administrator to make changes to the
* translations database.
*
* @author tseeker
*/
public interface I18NAdministration
{
/**
* @return the set of all languages identifiers, including languages that are not 100% supported
*/
public Set< String > getLanguages( );
/**
* Obtains the name of a language
*
* @param language
* the language's identifier
* @return the language's name
* @throws UnknownLanguageException
* if the language does not exist
*/
public String getLanguageName( String language )
throws UnknownLanguageException;
/**
* Returns the ratio of translated strings in a language relative to the total amount of string
* definitions.
*
* @param language
* the language's identifier
* @return the language's support ratio
* @throws UnknownLanguageException
* if the language does not exist
*/
public double getLanguageSupport( String language )
throws UnknownLanguageException;
/**
* Adds a new, totally unsupported language.
*
* @param language
* the new language's identifier
* @param name
* the name of the new language
* @throws DuplicateLanguageException
* if the language identifier is already in use
*/
public void createLanguage( String language , String name )
throws DuplicateLanguageException;
/**
* Updates a language's name
*
* @param language
* the language's identifier
* @param name
* the new name of the language
* @throws UnknownLanguageException
* if the language does not exist
*/
public void setLanguageName( String language , String name )
throws UnknownLanguageException;
/**
* @return the set of all string identifiers
*/
public Set< String > getStrings( );
/**
* Accesses a string's translation.
*
* @param language
* the language identifier
* @param string
* the string identifier
* @return the translation for the specified string in the specified language, or null if the
* string has not been translated in this language
* @throws UnknownStringException
* if the string identifier is invalid
* @throws UnknownLanguageException
* if the language does not exist
*/
public String getTranslation( String language , String string )
throws UnknownStringException , UnknownLanguageException;
/**
* Modifies or creates a string's translation in a given language
*
* @param language
* the language identifier
* @param string
* the string identifier
* @param translation
* the new translated string
* @return true if the string was created, false if it was updated
* @throws UnknownStringException
* if the string identifier is invalid
* @throws UnknownLanguageException
* if the language does not exist
*/
public boolean updateTranslation( String language , String string , String translation )
throws UnknownStringException , UnknownLanguageException;
/**
* Creates a new string and adds some of its translations. For this method to work as expected,
* no 100% supported language must become unsupported.
*
* @param string
* the new string's identifier
* @param translations
* a map whose keys are language identifiers and whose values are translations.
* @throws DuplicateStringException
* if the new string's identifier already exists
* @throws UnknownLanguageException
* if one of the languages does not exist
* @throws InvalidUpdateException
* if the creation of the string would cause one or more of the currently supported
* languages to become unsupported
*/
public void createString( String string , Map< String , String > translations )
throws DuplicateStringException , UnknownLanguageException , InvalidUpdateException;
}

View file

@ -0,0 +1,22 @@
package com.deepclone.lw.interfaces.i18n;
/**
* Base class for all I18N-related exception, including both translation exceptions and
* administration exceptions.
*
* @author tseeker
*/
public abstract class I18NException
extends Exception
{
private static final long serialVersionUID = 1L;
public I18NException( String message )
{
super( message );
}
}

View file

@ -0,0 +1,30 @@
package com.deepclone.lw.interfaces.i18n;
/**
* The I18NManager interface is used to access the main I18N management bean.
*
* @author tseeker
*/
public interface I18NManager
{
/**
* Creates an administration session for an administrator.
*
* @param administrator
* the administrator editing the I18N database
* @return the administration session instance
*/
public I18NAdministration getAdminSession( int administrator );
/**
* Reloads all translations from the database. This should only be used if manual modifications
* are made to the DB for some reason.
*/
public void reload( );
}

View file

@ -0,0 +1,37 @@
package com.deepclone.lw.interfaces.i18n;
import java.util.HashSet;
import java.util.Set;
/**
* This exception is thrown by administration session objects when the creation of a new string
* would make previously supported languages unsupported.
*
* @author tseeker
*/
public class InvalidUpdateException
extends I18NException
{
private static final long serialVersionUID = 1L;
private Set< String > downgradedLanguages;
public InvalidUpdateException( Set< String > languages )
{
super( "would downgrade the following languages: " + languages.toString( ) );
this.downgradedLanguages = new HashSet< String >( languages );
}
/**
* @return the set of identifiers for languages that would have become unsupported
*/
public Set< String > getDowngradedLanguages( )
{
return new HashSet< String >( this.downgradedLanguages );
}
}

View file

@ -0,0 +1,22 @@
package com.deepclone.lw.interfaces.i18n;
/**
* Base class for exceptions that can be thrown by both the administration interface and the
* translator bean.
*
* @author tseeker
*/
public abstract class TranslationException
extends I18NException
{
private static final long serialVersionUID = 1L;
public TranslationException( String message )
{
super( message );
}
}

View file

@ -0,0 +1,65 @@
package com.deepclone.lw.interfaces.i18n;
import java.util.Set;
/**
* Translator service interface
*
* This interface defines the methods available on the Translator service. One such service should
* be present on all nodes. All Translator service instances are managed by the I18NManager service,
* which is shared between nodes and notifies Translator instances of database updates.
*
* @author tseeker
*
*/
public interface Translator
{
/**
* @return the list of supported languages
*/
public Set< String > getSupportedLanguages( );
/**
* Checks if a language is supported.
*
* @param language
* the identifier of the language
* @return true if the language is present and fully supported, false otherwise.
*/
public boolean isLanguageSupported( String language );
/**
* Returns the plain text name of a language from its identifier.
*
* @param language
* the identifier of the language
* @return the name of the language
* @throws UnknownLanguageException
* if the specified language does not exist
*/
public String getLanguageName( String language )
throws UnknownLanguageException;;
/**
* Translates a string specified using its identifier.
*
* @param language
* the identifier of the language to translate to
* @param string
* the identifier of the string to translate
* @return the string's translation
* @throws UnknownStringException
* if the string is unknown
* @throws UnknownLanguageException
* if the language does not exist or is not supported
*/
public String translate( String language , String string )
throws UnknownStringException , UnknownLanguageException;
}

View file

@ -0,0 +1,29 @@
package com.deepclone.lw.interfaces.i18n;
/**
* This exception is thrown when a language does not exist in the database or, in the case of the
* translator bean, if the language isn't fully supported.
*
* @author tseeker
*/
public final class UnknownLanguageException
extends TranslationException
{
private static final long serialVersionUID = 1L;
private String language;
public UnknownLanguageException( String language )
{
super( "the requested language '" + language + "' could not be found" );
this.language = language;
}
public String getLanguage( )
{
return this.language;
}
}

View file

@ -0,0 +1,30 @@
package com.deepclone.lw.interfaces.i18n;
/**
* This exception is thrown when a string identifier does not exist in the database.
*
* @author tseeker
*/
public final class UnknownStringException
extends TranslationException
{
private static final long serialVersionUID = 1L;
private String string;
public UnknownStringException( String string )
{
super( "the requested i18n string '" + string + "' could not be found" );
this.string = string;
}
public String getString( )
{
return this.string;
}
}

View file

@ -0,0 +1,15 @@
package com.deepclone.lw.interfaces.mailer;
/**
* This exception is thrown when a message is sent twice.
*
* @author tseeker
*/
public class AlreadySentException
extends MailerException
{
private static final long serialVersionUID = 1L;
}

View file

@ -0,0 +1,53 @@
package com.deepclone.lw.interfaces.mailer;
/**
* A MailData instance allows an email to be prepared by substituting fields in the message template
* then sent either synchronously or asynchronously.
*
* @author tseeker
*/
public interface MailData
{
/**
* Sets the value of a template field
*
* @param identifier
* the field's identifier
* @param value
* the value with which the field is to be replaced
* @throws IllegalArgumentException
* if the identifier does not correspond to a field, if the value is null or if the
* field had already been set.
*/
public void setData( String identifier , Object value )
throws IllegalArgumentException;
/**
* Sends the message immediately, returning only after it has been sent.
*
* @throws AlreadySentException
* if the message had already been sent
* @throws MissingDataException
* if some of the template fields have not been set
* @throws NotSentException
* if the mail could not be sent
*/
public void sendNow( )
throws AlreadySentException , MissingDataException , NotSentException;
/**
* Queue the message so that it may be sent asynchronously.
*
* @throws AlreadySentException
* if the message had already been sent
* @throws MissingDataException
* if some of the template fields have not been set
*/
public void queue( )
throws AlreadySentException , MissingDataException;
}

View file

@ -0,0 +1,35 @@
package com.deepclone.lw.interfaces.mailer;
import com.deepclone.lw.interfaces.i18n.TranslationException;
/**
* Mailer bean interface
*
* This interface is meant to be implemented by the server's mailer bean.
*
* @author tseeker
*/
public interface Mailer
{
/**
* This method generates a MailData instance from a template found in the internationalisation
* database.
*
* @param language
* the language identifier
* @param contentsDef
* the string identifier for the mail's template
* @param target
* the address to which the mail is to be sent
* @return the mail data instance
* @throws TranslationException
* when retrieving the template from the database fails
*/
public MailData createMail( String language , String contentsDef , String target )
throws TranslationException;
}

View file

@ -0,0 +1,33 @@
package com.deepclone.lw.interfaces.mailer;
/**
* Base class for the mailer bean's exceptions
*
* @author tseeker
*/
public abstract class MailerException
extends Exception
{
private static final long serialVersionUID = 1L;
public MailerException( )
{
super( );
}
public MailerException( String message )
{
super( message );
}
public MailerException( Throwable cause )
{
super( cause );
}
}

View file

@ -0,0 +1,21 @@
package com.deepclone.lw.interfaces.mailer;
/**
* This exception is thrown when a template field has not been assigned a value.
*
* @author tseeker
*/
public class MissingDataException
extends MailerException
{
private static final long serialVersionUID = 1L;
public MissingDataException( String fieldName )
{
super( fieldName );
}
}

View file

@ -0,0 +1,21 @@
package com.deepclone.lw.interfaces.mailer;
/**
* This exception is thrown when an email could not be sent.
*
* @author tseeker
*/
public class NotSentException
extends MailerException
{
private static final long serialVersionUID = 1L;
public NotSentException( Throwable cause )
{
super( cause );
}
}

View file

@ -0,0 +1,46 @@
package com.deepclone.lw.interfaces.msg;
import com.deepclone.lw.cmd.admin.adata.Administrator;
import com.deepclone.lw.cmd.msgdata.MessageType;
import com.deepclone.lw.cmd.admin.msg.*;
public interface AdminMessages
{
public GetMessagesResponse getMessages( Administrator admin , boolean inbox );
public ReadMessageResponse getMessage( Administrator admin , boolean inbox , long id );
public void deleteMessages( Administrator admin , boolean inbox , long[] selection );
public void markRead( Administrator admin , long[] selection );
public void markUnread( Administrator admin , long[] selection );
public ComposeMessageResponse prepareBlankMessage( Administrator admin );
public ComposeMessageResponse prepareMessageTo( Administrator admin , MessageType type , int id );
public ComposeMessageResponse sendMessage( Administrator admin , MessageType type , String target , String title ,
String contents , boolean simulate );
public ComposeMessageResponse sendReply( Administrator admin , boolean inbox , long replyTo , MessageType type ,
String target , String title , String contents , boolean simulate );
public ComposeMessageResponse prepareReply( Administrator admin , boolean inbox , long id );
public void sendSpam( Administrator admin , String title , String body );
}

View file

@ -0,0 +1,48 @@
package com.deepclone.lw.interfaces.msg;
import com.deepclone.lw.cmd.msgdata.MessageType;
import com.deepclone.lw.cmd.player.msgs.ComposeMessageResponse;
import com.deepclone.lw.cmd.player.msgs.GetMessagesResponse;
import com.deepclone.lw.cmd.player.msgs.ListTargetsResponse;
import com.deepclone.lw.cmd.player.msgs.ReadMessageResponse;
public interface EmpireMessages
{
public GetMessagesResponse getMessages( int empireId , boolean inbox );
public ReadMessageResponse getMessage( int empireId , boolean inbox , long id );
public void deleteMessages( int empireId , boolean inbox , long[] selection );
public void markRead( int empireId , long[] selection );
public void markUnread( int empireId , long[] selection );
public ComposeMessageResponse prepareBlankMessage( int empireId );
public ComposeMessageResponse prepareMessageTo( int empireId , MessageType type , int id );
public ComposeMessageResponse sendMessage( int empireId , MessageType type , String target , String title ,
String contents , boolean simulate );
public ComposeMessageResponse sendReply( int empireId , boolean inbox , long replyTo , MessageType type ,
String target , String title , String contents , boolean simulate );
public ComposeMessageResponse prepareReply( int empireId , boolean inbox , long id );
public ListTargetsResponse getTargets( int empireId );
}

View file

@ -0,0 +1,44 @@
package com.deepclone.lw.interfaces.msg;
import java.util.List;
import com.deepclone.lw.cmd.msgdata.MessageType;
import com.deepclone.lw.sqld.msgs.InboxRecord;
public interface MessageBoxDAO
{
public int sendMessage( boolean admin , int empireId , MessageType type , String target , String title ,
String contents , boolean simulate );
public List< InboxRecord > getList( boolean admin , int id , boolean inbox );
public void markRead( boolean admin , int userId , long[] ids );
public void markRead( boolean admin , int userId );
public void markUnread( boolean admin , int userId , long[] ids );
public void markUnread( boolean admin , int userId );
public void delete( boolean admin , int userId , boolean inbox , long[] ids );
public void delete( boolean admin , int userId , boolean inbox );
public void clearCache( );
public void sendSpam( int adminId , String title , String body );
}

View file

@ -0,0 +1,20 @@
package com.deepclone.lw.interfaces.msg;
import java.util.List;
import java.util.Map;
import com.deepclone.lw.sqld.msgs.InboxRecord;
import com.deepclone.lw.sqld.msgs.MessageDataRecord;
public interface MessageContentCache
{
public Map< Long , MessageDataRecord > getContent( List< InboxRecord > messages );
public void clearCache( );
}

View file

@ -0,0 +1,14 @@
package com.deepclone.lw.interfaces.msg;
public interface MessageExtractor
{
public String getSender( );
public String getSubject( );
public String getContents( );
}

View file

@ -0,0 +1,16 @@
package com.deepclone.lw.interfaces.msg;
import com.deepclone.lw.sqld.msgs.MessageDataRecord;
public interface MessageFormatRegistry
{
public void addFormatter( MessageFormatter formatter );
public MessageFormatter getFormatter( MessageDataRecord contents );
}

View file

@ -0,0 +1,18 @@
package com.deepclone.lw.interfaces.msg;
import java.util.Set;
import com.deepclone.lw.sqld.msgs.FormatType;
import com.deepclone.lw.sqld.msgs.InboxRecord;
import com.deepclone.lw.sqld.msgs.MessageDataRecord;
public interface MessageFormatter
{
public Set< FormatType > getFormats( );
public MessageExtractor getExtractor( InboxRecord envelope , MessageDataRecord contents , String language );
}

View file

@ -0,0 +1,21 @@
package com.deepclone.lw.interfaces.msg;
import java.util.List;
import com.deepclone.lw.sqld.msgs.*;
public interface MessageRecordsDAO
{
public List< TextMessageRecord > getTextMessages( List< Long > ids );
public List< EventTypeRecord > getEventTypes( List< Long > ids );
public List< EventRecord > getEvents( EventType type , List< Long > ids );
}

View file

@ -0,0 +1,24 @@
package com.deepclone.lw.interfaces.msg;
import java.util.List;
import com.deepclone.lw.sqld.msgs.InboxRecord;
import com.deepclone.lw.sqld.msgs.NotificationsRecord;
public interface NotificationsDAO
{
public boolean isRecapTime( );
public List< NotificationsRecord > getNotificationRecords( boolean instant );
public List< InboxRecord > listMessages( int empireId , long maxId , boolean instant , boolean nPrivate ,
boolean nInternal , boolean nAlliance , boolean nAdmin );
public void cleanupMessages( );
}

View file

@ -0,0 +1,42 @@
package com.deepclone.lw.interfaces.naming;
/**
* Empire/player name manager exception
*
* This exception is used by {@link EmpireNamesDAO} to indicate that something went wrong in the
* name creation or modification code.
*
* @author tseeker
*/
public class EmpireNameException
extends Exception
{
private static final long serialVersionUID = 1L;
/** Possible causes for this exception */
public static enum Error {
/** Attempting to use a banned name */
BANNED ,
/** Attempting to use a name which already exists in the DB */
UNAVAILABLE ,
}
/** Actual error code */
private Error error;;
public EmpireNameException( Error error )
{
super( error.toString( ) );
this.error = error;
}
/** @return the error code for the exception */
public Error getError( )
{
return this.error;
}
}

View file

@ -0,0 +1,48 @@
package com.deepclone.lw.interfaces.naming;
/**
* Map object name manager exception
*
* This exception is thrown by {@link MapNamesDAO} to indicate that something went wrong. It
* carries an error code indicating the nature of the problem.
*
* @author tseeker
*/
public class MapNameException
extends Exception
{
private static final long serialVersionUID = 1L;
/** Possible causes for this exception */
public static enum Error {
/** Attempting to use a banned name */
BANNED ,
/** Attempting to use a name which already exists in the DB */
UNAVAILABLE ,
/** Attempting a rename too early after the previous one */
TOO_EARLY ,
/** Attempting to validate a name that's already been validated */
VALIDATED ,
/** Attempting to validate a name that's never been modified by a player */
NOT_RENAMED
};
/** Actual error code */
private Error error;;
public MapNameException( Error error )
{
super( error.toString( ) );
this.error = error;
}
/** @return the error code for the exception */
public Error getError( )
{
return this.error;
}
}

View file

@ -0,0 +1,32 @@
package com.deepclone.lw.interfaces.naming;
import com.deepclone.lw.cmd.admin.adata.Administrator;
import com.deepclone.lw.cmd.admin.naming.GetNamesResponse;
import com.deepclone.lw.cmd.admin.naming.NameType;
import com.deepclone.lw.cmd.admin.naming.NamesSummaryResponse;
public interface NamesManager
{
public NamesSummaryResponse getSummary( Administrator admin );
public GetNamesResponse getNames( Administrator admin , NameType type );
public void validateMapNames( Administrator admin , int[] ids );
public void allowMapNameChanges( Administrator admin , int[] ids );
public void rejectMapNames( Administrator admin , int[] ids , boolean ban );
public void rejectEmpireNames( Administrator admin , int[] ids , boolean ban );
public void rejectAllianceNames( Administrator admin , int[] ids );
}

View file

@ -0,0 +1,45 @@
package com.deepclone.lw.interfaces.naming;
import java.util.List;
import java.util.Map;
import com.deepclone.lw.cmd.admin.naming.Name;
import com.deepclone.lw.cmd.admin.naming.NameType;
import com.deepclone.lw.sqld.accounts.Account;
public interface NamingDAO
{
public List< String > getEmpireNames( int id );
public Integer getCurrentEmpire( Account account );
public int renamePlanet( int id , String name );
public Map< NameType , Long > countNames( );
public List< Name > getNames( NameType type );
void validateMapName( int administrator , int name );
public void allowMapNameChange( int administrator , int name );
public void rejectMapName( int administrator , int name , boolean ban );
public void rejectEmpireName( int administrator , int empire , boolean ban );
public void rejectAllianceName( int administrator , int alliance );
}

View file

@ -0,0 +1,46 @@
package com.deepclone.lw.interfaces.prefs;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class AccountPreferences
{
private final Map< String , PreferenceGroup > groups = new HashMap< String , PreferenceGroup >( );
private final List< String > groupOrder = new LinkedList< String >( );
private final Map< String , String > prefGroups;
public AccountPreferences( List< PreferenceGroup > groups , Map< String , String > prefGroups )
{
for ( PreferenceGroup group : groups ) {
this.groups.put( group.getName( ) , group );
this.groupOrder.add( group.getName( ) );
}
this.prefGroups = prefGroups;
}
public List< PreferenceGroup > getGroups( )
{
List< PreferenceGroup > g = new LinkedList< PreferenceGroup >( );
for ( String gn : groupOrder ) {
g.add( this.groups.get( gn ) );
}
return g;
}
public < T > T getPreference( String name , Class< T > type )
{
String gn = this.prefGroups.get( name );
return this.groups.get( gn ).getPreference( name ).getValue( type );
}
}

View file

@ -0,0 +1,75 @@
package com.deepclone.lw.interfaces.prefs;
public class Preference
{
private String name;
private PreferenceGroup group;
private String displayName;
private String description;
private PreferenceType< ? > type;
private String value;
public Preference( String name , PreferenceGroup group , String displayName , String description ,
PreferenceType< ? > type , String value )
{
this.name = name;
this.group = group;
this.displayName = displayName;
this.description = description;
this.type = type;
this.value = value;
this.group.addPreference( this );
}
public String getName( )
{
return name;
}
public PreferenceGroup getGroup( )
{
return group;
}
public String getDisplayName( )
{
return displayName;
}
public String getDescription( )
{
return description;
}
public PreferenceType< ? > getType( )
{
return type;
}
public String getDBValue( )
{
return this.value;
}
@SuppressWarnings( "unchecked" )
public < T > T getValue( Class< T > type )
{
return ( (PreferenceType< T >) this.type ).valueOf( this.value , type );
}
}

View file

@ -0,0 +1,25 @@
package com.deepclone.lw.interfaces.prefs;
public class PreferenceDefinitionException
extends Exception
{
/** Serialisation version identifier */
private static final long serialVersionUID = 1L;
public static enum Error {
MISSING_GROUP ,
MISSING_DEFINITION ,
MISSING_STRING ,
INVALID_TYPE
}
public final Error error;
public PreferenceDefinitionException( Error error )
{
this.error = error;
}
}

View file

@ -0,0 +1,71 @@
package com.deepclone.lw.interfaces.prefs;
import java.util.List;
import com.deepclone.lw.cmd.admin.adata.Administrator;
import com.deepclone.lw.cmd.player.gdata.account.PrefCategory;
/**
* Interface for the preference definitions management bean.
*
* @author tseeker
*/
public interface PreferenceDefinitions
{
/**
* Registers a group of preferences.
*
* @param name
* programmatic name of the group
* @param displayName
* internationalised string identifier
* @throws PreferenceDefinitionException
* when the display name string doesn't exist (with the
* {@link PreferenceDefinitionException.Error#MISSING_STRING} error code)
* @throws IllegalArgumentException
* if one of the parameters is <code>null</code>
*/
public void registerGroup( String name , String displayName )
throws PreferenceDefinitionException , IllegalArgumentException;
/**
* Registers a new type of user preference.
*
* @param name
* programmatic name of the preference
* @param group
* programmatic name of the group the preference is a part of
* @param displayName
* internationalised string identifier that allows the preference's name to be
* displayed
* @param displayDescription
* internationalised string identifier that allows the preference's description to be
* displayed (may be <code>null</code>)
* @param defaultValue
* default value of the preference
* @throws PreferenceDefinitionException
* when the group doesn't exist (with the
* {@link PreferenceDefinitionException.Error#MISSING_GROUP} error code), when the
* display name or description string doesn't exist (with the
* {@link PreferenceDefinitionException.Error#MISSING_STRING} error code) or if the
* preference already exists but is defined as having a different type (with the
* {@link PreferenceDefinitionException.Error#INVALID_TYPE} error code).
* @throws IllegalArgumentException
* if one of the mandatory arguments is <code>null</code>
*/
public void registerPreference( String name , String group , String displayName , String displayDescription ,
Object defaultValue )
throws PreferenceDefinitionException , IllegalArgumentException;
public List< PrefCategory > getDefaults( );
public void setDefault( Administrator admin , String preference , String value );
}

View file

@ -0,0 +1,60 @@
package com.deepclone.lw.interfaces.prefs;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class PreferenceGroup
{
private String name;
private String display;
private final List< Preference > definitions = new LinkedList< Preference >( );
private final Map< String , Preference > byName = new HashMap< String , Preference >( );
public PreferenceGroup( String name , String display )
{
this.name = name;
this.display = display;
}
public String getName( )
{
return name;
}
public String getDisplay( )
{
return display;
}
public void addPreference( Preference def )
{
this.definitions.add( def );
this.byName.put( def.getName( ) , def );
}
public List< Preference > getPreferences( )
{
return this.definitions;
}
public Preference getPreference( String name )
{
return this.byName.get( name );
}
}

View file

@ -0,0 +1,24 @@
package com.deepclone.lw.interfaces.prefs;
import java.util.Map;
public interface PreferenceType< T >
{
public T valueOf( String dbValue , Class< T > type );
public Object valueOf( String inValue );
public String convert( Object value );
public Map< String , String > getChoices( );
public Class< T > getType( );
}

View file

@ -0,0 +1,12 @@
package com.deepclone.lw.interfaces.prefs;
public interface PreferenceTypesRegistry
{
public < T > PreferenceType< T > getType( Class< T > jType );
public PreferenceType< ? > getType( String typeName );
}

View file

@ -0,0 +1,44 @@
package com.deepclone.lw.interfaces.prefs;
import java.util.Map;
import com.deepclone.lw.sqld.accounts.Account;
/**
* Interface for the account preferences management bean.
*
* @author tseeker
*/
public interface PreferencesDAO
{
/**
* Reads all preferences from an account.
*
* <p>
* This method reads all preferences associated to an account. The default value is used if a
* preference definition exists but no such preference is set for the account.
*
* @param account
* account whose preferences are to be read.
*/
public AccountPreferences getPreferences( Account account );
public AccountPreferences getPreferences( int accountId );
/**
* Resets an account's preferences.
*
* @param account
* account whose preferences are to be reset
*/
public void resetPreferences( Account account );
void setPreferences( Account account , Map< String , String > values );
}

View file

@ -0,0 +1,104 @@
package com.deepclone.lw.interfaces.session;
import java.net.InetAddress;
import java.util.Date;
import com.deepclone.lw.cmd.admin.users.SessionTerminationType;
/**
* Server-side session interface.
*
* <p>
* This interface provides session type definers (as defined by {@link SessionTypeDefiner}) limited
* access to server-side session data.
*
* @author tseeker
*/
public interface ServerSession
{
/**
* @return the session's identifier (may be null when the session is being initialised)
*/
public String getIdentifier( );
/**
* @return the identifier of the client on behalf of which the session was created
*/
public String getClient( );
/**
* @return the IP address of the client on behalf of which the session was created
*/
public InetAddress getAddress( );
/**
* @return the session's current authentication challenge string
*/
public String getChallenge( );
/**
* Sets the session's expiration date
*
* @param date
* new expiration date
*/
public void setExpirationDate( Date date );
/**
* @return the type of session termination or <code>null</code> if the session is not being
* terminated
*/
public SessionTerminationType getTerminationType( );
/**
* Terminates the session.
*
* <p>
* This method can be called by session type definers which need to destroy a session. It will
* set the termination type to {@link SessionTerminationType#MANUAL} and call back
* {@link SessionTypeDefiner#terminate(ServerSession)}.
*/
public void terminate( );
/**
* Terminates the session.
*
* <p>
* This method can be called by session type definers which need to destroy a session and give a
* specific reason.
*/
public void terminate( SessionTerminationType reason );
/**
* Stores data into the session.
*
* @param key
* key with which the specified value is to be associated
* @param value
* value to be associated with the specified key
*/
public void put( String key , Object value );
/**
* Retrieves data from the session.
*
* @param key
* the key whose associated value is to be returned
* @param type
* expected type of the value
*/
public < T > T get( String key , Class< T > type );
}

View file

@ -0,0 +1,34 @@
package com.deepclone.lw.interfaces.session;
import com.deepclone.lw.session.SessionAccessor;
/**
* Session manager interface.
*
* <p>
* This interface, implemented by the session management bean, extends the Legacy Worlds
* {@link SessionAccessor} interface and adds a method allowing {@link SessionTypeDefiner} instances
* to be registered.
*
* @author tseeker
*/
public interface SessionManager
extends SessionAccessor
{
/**
* Registers a session type definer.
*
* <p>
* This method adds support for a session type using the specified session type definer. If a
* session type with the same name already exists, it is replaced.
*
* @param definer
* the session type definer to register.
*/
public void registerSessionType( SessionTypeDefiner definer );
}

View file

@ -0,0 +1,125 @@
package com.deepclone.lw.interfaces.session;
import com.deepclone.lw.cmd.admin.users.SessionTerminationType;
import com.deepclone.lw.session.Command;
import com.deepclone.lw.session.CommandResponse;
import com.deepclone.lw.session.SessionCommandException;
import com.deepclone.lw.session.SessionStateException;
/**
* Interface for session type definers.
*
* <p>
* This interface defines methods which allow sessions to be managed.
*
* @author tseeker
*/
public interface SessionTypeDefiner
{
/** @return the name of the session type */
public String getName( );
/**
* Initialises a session.
*
* <p>
* This method should initialise the specified session, setting its initial data and expiration
* date. When the method is called by the {@link SessionManager}, the session has no identifier
* - it is only assigned once initialisation has completed.
*
* @param session
* the session to initialise
*/
public void initialise( ServerSession session );
/**
* Determines whether the specified session has undergone authentication.
*
* @param session
* the session whose status is to be determined.
* @return <code>true</code> if the session has undergone authentication or doesn't need to
* authenticate, <code>false</code> if authentication is required
*/
public boolean isAuthenticated( ServerSession session );
/**
* Returns the current state of the session.
*
* <p>
* This method returns the current state of an authenticated session. It is useful for session
* definers that implement multi-state sessions, accepting different sets of commands in each
* state.
*
* @param session
* the session whose state is to be determined
* @return the session's state.
*/
public String getState( ServerSession session );
/**
* Authenticates a session.
*
* <p>
* This method attempts to authenticate a session, modifying the session's data accordingly if
* successful.
*
* @param session
* the session being authenticated
* @param identifier
* authentication identifier (for example an account's mail address)
* @param sha1Hash
* SHA-1 hash of the challenge response
* @param md5Hash
* MD5 hash of the challenge response
* @throws SessionStateException
* if the session type doesn't support authentication or if the session had already
* undergone authentication.
*/
public void authenticate( ServerSession session , String identifier , String sha1Hash , String md5Hash )
throws SessionStateException;
/**
* Executes a command.
*
* <p>
* This method executes the specified command in the session's context, returning the command's
* results.
*
* @param session
* the session whose context is to be used when executing the command
* @param command
* the command to execute
* @return whatever the command execution yields.
* @throws SessionStateException
* if the session type requires authentication and the session is not authenticated.
* @throws SessionCommandException
* if the session type does not support the specified command.
*/
public CommandResponse execute( ServerSession session , Command command )
throws SessionStateException , SessionCommandException;
/**
* Handles session termination.
*
* <p>
* This method will execute code specific to a session type when a session is being terminated
* (either through the session type definer itself or for other reasons).
*
* @param session
* the session that's being terminated.
* @param reason
* the reason why the session's being terminated
*/
public void terminate( ServerSession session , SessionTerminationType reason );
}

View file

@ -0,0 +1,122 @@
package com.deepclone.lw.interfaces.sys;
/**
* This class is used by beans which define constants in order to notify the constants manager of
* their existence and specifics.
*
* @author tseeker
*/
public final class ConstantDefinition
{
/** The constant's name, as it is used in the code */
public final String name;
/** The human-readable category name used in the administration interface */
public final String category;
/** The constant's description used in the administrative interface */
public final String description;
/** The optional minimal value */
public final Double minValue;
/** The optional maximal value */
public final Double maxValue;
/** The constant's default value */
public final Double defaultValue;
/**
* Creates a constant definition with no constraints.
*
* @param name
* the constant's name
* @param category
* the constant's category
* @param description
* the constant's description
* @param value
* the constant's default value
*/
public ConstantDefinition( String name , String category , String description , Double value )
{
this.name = name;
this.category = category;
this.description = description;
this.defaultValue = value;
this.maxValue = this.minValue = null;
}
/**
* Creates a constant definition with a single constraint.
*
* @param name
* the constant's name
* @param category
* the constant's category
* @param description
* the constant's description
* @param value
* the constant's default value
* @param constraint
* a constraint to apply on the constant's definition
* @param isMinimal
* whether the constraint is the minimal or maximal value
* @throws IllegalArgumentException
* if the default value is out of bounds
*/
public ConstantDefinition( String name , String category , String description , Double value , Double constraint ,
boolean isMinimal )
throws IllegalArgumentException
{
if ( isMinimal && value < constraint || !isMinimal && value > constraint ) {
throw new IllegalArgumentException( );
}
this.name = name;
this.category = category;
this.description = description;
this.defaultValue = value;
this.maxValue = isMinimal ? null : constraint;
this.minValue = isMinimal ? constraint : null;
}
/**
* Creates a constant definition with two constraints.
*
* @param name
* the constant's name
* @param category
* the constant's category
* @param description
* the constant's description
* @param value
* the constant's default value
* @param min
* the constant's minimal value
* @param max
* the constant's maximal value
* @throws IllegalArgumentException
* if the minimal is greater than the maximal or if the default value is out of
* bounds
*/
public ConstantDefinition( String name , String category , String description , Double value , Double min ,
Double max )
throws IllegalArgumentException
{
if ( min > max || value < min || value > max ) {
throw new IllegalArgumentException( );
}
this.name = name;
this.category = category;
this.description = description;
this.defaultValue = value;
this.maxValue = max;
this.minValue = min;
}
}

View file

@ -0,0 +1,48 @@
package com.deepclone.lw.interfaces.sys;
import java.util.Collection;
import java.util.Set;
/**
* This is the constants administrative interface, which allows constants to be listed and modified
* by the game's administrators.
*
* @author tseeker
*/
public interface ConstantsAdministration
{
/** @return the set of constant categories */
public Set< String > getCategories( );
/**
* List all constants in a category. The constant definition objects that are returned have the
* constant's current value set as their default value field.
*
* @param category
* the name of the category to list
* @return the list of constants in a given category or an empty list if the category does not
* exist
*/
public Collection< ConstantDefinition > getConstants( String category );
/**
* Modifies a constant and notifies all constant user components of the change.
*
* @param name
* the constant's name
* @param value
* the constant's new value
* @throws UnknownConstantError
* if the name doesn't match any actual constant
* @throws InvalidConstantValue
* if the specified value is out of bounds
*/
public void setConstant( String name , Double value )
throws UnknownConstantError , InvalidConstantValue;
}

View file

@ -0,0 +1,63 @@
package com.deepclone.lw.interfaces.sys;
import java.util.Collection;
import java.util.Set;
/**
* The constants management service provides a way for system constants to be accessed from a
* central location. All constants are loaded in main memory, and can be modified through an
* administrative interface.
*
* @author tseeker
*
*/
public interface ConstantsManager
{
/**
* Registers a set of constants; if the constants already exist in the database, their
* constraints are updated and their value is only modified if it violates the constraints. If
* they do not exist yet, they are created.
*
* If constants are modified or created, and if there are users registered for these constants,
* they will be notified.
*
* @param definitions
* the set of constant definitions to register
*/
public void registerConstants( Collection< ConstantDefinition > definitions );
/**
* Registers a constants user, which will need to be informed of the constants' changes. If the
* required constants have not been registered yet, the user instance will not be notified.
*
* @param user
* the constants user component to register
* @param constants
* set of constant names the user wants to be informed about
*/
public void registerUser( ConstantsUser user , Set< String > constants );
/**
* Unregisters a constants user.
*
* @param user
* the constants user component to unregister
*/
public void unregisterUser( ConstantsUser user );
/**
* Creates an administrative interface for a specific administrator.
*
* @param admin
* the administrator making changes to the constants.
* @return the administrative interface
*/
public ConstantsAdministration getAdminSession( int admin );
}

View file

@ -0,0 +1,32 @@
package com.deepclone.lw.interfaces.sys;
import java.util.Map;
/**
* This interface is implemented by beans which need to access system constants and be informed if
* the constants are modified.
*
* @author tseeker
*
*/
public interface ConstantsUser
{
/**
* This method will be called by the constants manager when the constants user registers itself
* or whenever one of the constants needed by the user is modified.
*
* @param initial
* true if the call is being issued after registration, false otherwise
* @param values
* a map that associates updated constant names to their new values
* @throws Exception
* for whatever reasons.
*/
public void setConstants( boolean initial , Map< String , Double > values )
throws Exception;
}

View file

@ -0,0 +1,10 @@
package com.deepclone.lw.interfaces.sys;
public class EndAutowiredTransaction
extends RuntimeException
{
private static final long serialVersionUID = 1L;
}

View file

@ -0,0 +1,17 @@
package com.deepclone.lw.interfaces.sys;
/**
* This exception is thrown by the constants administrative interface when an administrator attempts
* to set a constraint that is out of bounds.
*
* @author tseeker
*
*/
public class InvalidConstantValue
extends Exception
{
private static final long serialVersionUID = 1L;
}

View file

@ -0,0 +1,27 @@
package com.deepclone.lw.interfaces.sys;
import java.io.Serializable;
import java.sql.Timestamp;
public final class MaintenanceData
implements Serializable
{
/** Serialisation version identifier */
private static final long serialVersionUID = 1L;
public final Timestamp start;
public final Timestamp end;
public final String reason;
public MaintenanceData( Timestamp start , Timestamp end , String reason )
{
this.start = start;
this.end = end;
this.reason = reason;
}
}

View file

@ -0,0 +1,27 @@
package com.deepclone.lw.interfaces.sys;
public class MaintenanceStatusException
extends Exception
{
/** Serialisation version identifier */
private static final long serialVersionUID = 1L;
public final MaintenanceData maintenanceData;
public MaintenanceStatusException( )
{
super( "not under maintenance" );
this.maintenanceData = null;
}
public MaintenanceStatusException( MaintenanceData data )
{
super( "under maintenance" );
this.maintenanceData = data;
}
}

View file

@ -0,0 +1,53 @@
package com.deepclone.lw.interfaces.sys;
public interface SystemStatus
{
/**
* Checks whether the system is currently under maintenance.
*
* @return <code>null</code> or maintenance record
*/
public MaintenanceData checkMaintenance( );
/**
* Activates maintenance mode.
*/
public void startMaintenance( int adminId , String reason , int duration )
throws MaintenanceStatusException;
/**
* Updates maintenance mode duration.
*/
public void updateMaintenance( int adminId , int durationFromNow )
throws MaintenanceStatusException;
/**
* Exits maintenance mode.
*/
public void endMaintenance( int adminId )
throws MaintenanceStatusException;
/**
* Starts a new tick.
*
* @return new tick's identifier
*/
public long startTick( )
throws TickStatusException , MaintenanceStatusException;
/**
* Checks if there is a "stuck" tick.
*
* @return current tick's identifier or <code>null</code> if there is no stuck tick
*/
public Long checkStuckTick( )
throws MaintenanceStatusException;
}

View file

@ -0,0 +1,25 @@
package com.deepclone.lw.interfaces.sys;
public class TickStatusException
extends Exception
{
/** Serialisation version identifier */
private static final long serialVersionUID = 1L;
public final Long tickIdentifier;
public TickStatusException( )
{
super( "no tick in progress" );
this.tickIdentifier = null;
}
public TickStatusException( long id )
{
super( "tick in progress" );
this.tickIdentifier = id;
}
}

View file

@ -0,0 +1,78 @@
package com.deepclone.lw.interfaces.sys;
/**
* System task scheduler
*
* This interface provides access to the system task scheduler, which is used for everything that is
* supposed to happen at a regular interval (from log cleaning to ticks).
*
* @author tseeker
*/
public interface Ticker
{
/** Task execution frequencies */
public enum Frequency {
/** Tasks that are meant to be executed every five seconds */
HIGH ,
/** Tasks that are meant to be executed every thirty seconds */
MEDIUM ,
/** Tasks that are meant to be executed every minute */
MINUTE ,
/** Tasks that are meant to be executed every five minutes */
LOW
}
/**
* Registers a new task.
*
* This method may be called to register a new task in the system ticker. The ticker will use a
* weak reference to store the task's execution instance.
*
* @param frequency
* task execution frequency
* @param name
* task name
* @param task
* runnable instance to be executed at the specified frequency
*/
public void registerTask( Ticker.Frequency frequency , String name , Runnable task );
/**
* Pauses the ticker.
*
* This method pauses the ticker. Once the method is called, no new tasks will be started;
* however, the method will wait for any currently running tasks before returning.
*
* @throws IllegalStateException
* if the ticker was already paused
*/
public void pause( )
throws IllegalStateException;
/**
* Restarts the ticker.
*
* This method attempts to restart the ticker after it has been paused.
*
* @throws IllegalStateException
* if the ticker was already running.
*/
public void unpause( )
throws IllegalStateException;
/**
* @return <code>true</code> the ticker is currently running or <code>false</code> if it has
* been paused.
*/
public boolean isActive( );
}

View file

@ -0,0 +1,24 @@
package com.deepclone.lw.interfaces.sys;
import java.util.List;
import com.deepclone.lw.cmd.admin.tick.TickerTaskInfo;
public interface TickerManager
{
public List< TickerTaskInfo > getTasks( );
public void startTask( int administrator , int id );
public void stopTask( int administrator , int id );
public void setTaskStart( int administrator , int id , long time );
}

View file

@ -0,0 +1,21 @@
package com.deepclone.lw.interfaces.sys;
/**
* This exception is thrown when a constant name doesn't match an actual constant.
*
* @author tseeker
*/
public class UnknownConstantError
extends Exception
{
private static final long serialVersionUID = 1L;
public UnknownConstantError( String constant )
{
super( constant );
}
}

View file

@ -0,0 +1,16 @@
package com.deepclone.lw.interfaces.sys;
public class WiringException
extends RuntimeException
{
private static final long serialVersionUID = 1L;
public WiringException( Throwable cause )
{
super( cause );
}
}